A couple of days ago, this discussion about the difficulty of getting an AI to play Mario Kart started up on a post I made. I decided to start doing some research into gaming/speedrunning AI and it has ultimately led to me staring at a screen watching an AI try to complete 1-1 in Super Mario Bros for the past two days.
The AI is a simple Lua script that runs in an emulator, but it was designed specifically for Super Mario World. There are some issues I would like to straighten out with it, as it can not complete 1-1 yet. Basically, the AI presses random buttons until it starts to move to the right. Moving to the right will give it a progressively higher score, and if it stops or dies, it will reset and try again. It then takes the best attempts and expands on them.
I've been observing some of the intricacies of how the AI functions, and I think that with some tweaks, it could actually learn to complete quite a few of the levels in Mario.
The source code is here. It runs in the FCEUX emulator and is very easy to set up. It'd be cool to turn this into a little project and expand on it, because it really is fascinating to watch and I don't think it will be that difficult to do.
No, there is no kind of input specified in the script. When it starts, it will reset around 50-100 times without moving right. When it moves right, it will start getting score, until it either stops for too long or dies. It will then begin to build on all of its recorded strategies, slightly prioritising the ones that gave it a better score. The score also seems to be partially based on speed, which is causing some issues as it will sometimes recognise an attempt that is shorter but faster than another attempt as being better.
I do not actually know how it works specifically, as I haven't looked too much at the code, but it is only around 800 lines of lua. It is doing some stuff like reading ram values to "see" the level. But basically, it learns everything on its own with no outside input.