====== Infinite Super Mario AI ====== The other day I saw that there is a [[http://julian.togelius.com/mariocompetition2009/index.php|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 [[http://en.wikipedia.org/wiki/A*_search_algorithm|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 [[http://julian.togelius.com/mariocompetition2009/|here]]. Source-code of my entry is below, other entries can soon be found on Julians page. \\ \\ ====== Videos ====== The following videos show the AI in action. ++++ Long level | {{ youtube>medium:DlkMs4ZHHr8 }} ++++ ++++ Short level (with slowmotion part) | {{ youtube>medium:0s3d1LfjWCI }} ++++ ++++ AI follows mouse | {{ youtube>medium:qYluZRwrw9w }} ++++ ++++ AI follows mouse - slowmotion excerpt | {{ youtube>medium:J2shAMA0dfM }} ++++ \\ {{ :projects:marioscreen2.png?nolink |}} \\ ====== Android Live Wallpaper ====== 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 [[http://forum.xda-developers.com/showthread.php?t=710647|the corresponding forum post]]. \\ ====== Source Code ====== 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. \\ {{track>:projects:a-star_mario_ai_v1.1_robin_baumgarten.zip|Download source code||87802}} \\ ==== Overview: ==== * **AStarAgent.java**: The entry point of the source-code, called by the API. It calls the optimize() function in AStarSimulator.java * **AStarSimulator.java**: Contains the meat of the A* search. The SearchNode class contains a node, including its action, and a copy of the world state. The optimize() function sets up the A* planner, extracts the latest plan and returns an optimal action. search() contains the planning loop itself, which explores the search space. * **LevelScene.java**: This class contains most of the world-state, and holds the Mario-object and enemy objects. ==== How to get it to run: ==== * Download the competition mario code from [[http://julian.togelius.com/mariocompetition2009/|Julian's site]]. * Put my Mario AI into the src/competition/cig/robinbaumgarten/ folder * Launch \src\ch\idsia\scenarios\Play.java, changed so that it loads AStarAgent.java. * I've put some trouble-shooting hints on [[:projects:marioai:trouble|this page]]. ==== License ==== The source-code is published under the [[http://sam.zoy.org/wtfpl/|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. \\ \\ ====== Quick FAQ ====== ** 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, [[http://aigamedev.com/open/interviews/mario-ai/|read it here]]. [[projects:marioai:media|.]]