That is interesting Jeffw.
Do you have any links to examples of controlling a game in an editor with lua? I did find the lua manual:
http://www.lua.org/manual/5.1/
I've attached an example lua script I wrote a while back that tests for bias in the random number generator (RAM value 0x6018). Specifically, it tests if even random numbers are as likely as odd random numbers, and also if the previous random number being even vs odd affects the probability that the next one is even vs odd. I never found any bias with this script. When running the script a test is started by pressing 1 and stopped by pressing 2, at which point it will display the statistics it computed. Keep in mind I know hardly anything about lua programming and was mainly concerned with writing something that worked rather than making sure I was following good practices.
For the case of a DK AI instead of recording statistics on the value of the RNG each frame like this script does you will want to set the input using the joypad.set() function. A complete list of functions provided by mame-rr can be found here:
http://code.google.com/p/mame-rr/wiki/LuaScriptingFunctionsIn order to make the AI move in response to what is happening on the board, you will need to read values from RAM. Here are some useful RAM values that could help get you started. All values are in hexadecimal.
0x6203 - Mario's X position
0x6205 - Mario's Y position
0x6700 is the start of the barrel array. Each barrel has a 0x20 byte range in which information for that barrel is stored. So for example barrel 1 info is in 6700 to 671F, barrel 2 info is in 6720 to 673F, etc. Here are some offsets from a barrel's range starting point that contain some useful info:
offset 00 - barrel status indicator (value 00 means inactive, 01 means active, 02 means it's being deployed)
offset 01 - wild barrel indicator (value 00 for normal and 01 for wild barrel)
offset 03 - barrel x position
offset 05 - barrel y position
0x6400 is that start of the fire array. Like the barrel array each fireball/firefox has a 0x20 byte range. Here are some useful offsets:
offset 00 - fire status (value 00 means inactive, 01 means active)
offset 03 - fire x position
offset 05 - fire y position
If you guys want, I can see if I can release a full RAM map with the meaning of a whole bunch of other RAM values. You can always try to find out what other RAM values, such as other offsets in the fire/barrel array, do by observing their values using RAM watch as you play.