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.
The criteria for the SMW AI improving is extremely basic. All it really does is try to move right as much as possible, with a small incentive to go fast. It also has no starting point to work from, it just does stuff randomly until something good happens, and then it builds from that.
In SMK, the criteria for measuring progress is infinitely more complex. It needs a starting point to go from, because letting it hit random buttons is not going to produce the same level of results as it does in a 2d platformer. There are also issues with developing long term strategies. Imagine a square track, just 4 corners. Let us assume that the AI's starting point is a path that drives all the way around the track in the middle of the road. It mutates a lap attempt where it takes Corner 1 sharply, and saves time overall, so it memorises this action for going around Corner 1. But imagine that the line it takes around Corner 1 makes it impossible to hit an optimal angle on Corner 2, and the real best way to get around the first two corners is to not take the "best" line around Corner 1 in order to get a better average time around both corners.
This example only scratches the surface at how insanely complex a racing AI would be in comparison.