The other day I saw that there is a Super Mario Competition for a conference in September 2009. I decided that this was a fun project to hone my AI programming skills and started to write a little path planning AI, using A*. The source code for this can also be found on this page.
Update (6. Sept 09): My Mario AI has won both Mario competitions this year, the ICE-GIC conference held at Imperial College in July and the IEEE Computational Intelligence in Games symposium in Milan in September! It was a really close decision between the first three solutions though (all of which are using A*). Yay! Check the slides of the competition presentation here. Source-code of my entry is below, other entries can soon be found on Julians page.
The following videos show the AI in action.
A member from the XDA developer forum, Pikipirs, has ported Infinite Super Mario and my AI to Android and made an awesome live wallpaper! You can find more about it at the corresponding forum post.
As the CIG competition is now closed, I've published the source code of my A* search bot here. The source code is annotated and reasonably well structured. However, it might not be the simplest to understand in parts, as it wasn't written to show how A* works, but hacked together in order to play Mario well. I've tried to make it clear what's what, though.
Download source code
The source-code is published under the WTFPL. Basically, do whatever you like with the source code.
Of course, if you use it, I'd be happy if you mention that it has been developed by me, and give me a heads up.
A* heuristic: Get to the right border of the screen as fast as possible. Avoid being hurt.
Development time: Didn't track it, my guesstimate is 20-30 hours for the core functionality. Another 30 for playing around with different heuristics.
Most headache: Java serialisation of the game state while searching, debugging the physics simulation engine.
Real time: It does run in real-time, although it needs a decent computer to get enough search depth to find its way out. With 24 fps, you get about 40ms each tick to plan. I search for several ticks before updating the search space to get a deeper searchdepth.
Does Mario still die? Yeah, sometimes he still falls into a pit (like it almost happened in the long video). When the AI can't avoid a spiky, it can get hurt (it might be able to avoid the spiky if it had more computing time, but the real-time constraint forbids this).
Best reply to the youtube video: “So I undestand correctly: da computer will play video games for us, so we have more free time? Way cool.”
More info: I've talked to Alex Champandard from AIGameDev.com about my Mario AI, read it here.