Inspiration

After reading a paper called NEAT: Evolving Increasingly Complex Neural Network Topologies published out of the University of Texas in 2000, we were inspired to test the limits of the algorithm by creating an implementation to learn one of our favourite classic games, Super Mario Bros. We've always found the concepts of machine learning and artificial intelligence incredibly interesting, so when we realized we could combine that passion with our love for games, we jumped at the opportunity.

What it does

crAIg starts out as an effectively blank canvas. He is dropped into level 1-1 of Super Mario Bros. with no knowledge of the game itself, what the game's goal is, or how to play. He has but one evolutionary instinct - to survive. crAIg 'breeds' himself using the algorithms and techniques explained in NEAT. Thousands of different crAIg iterations are created, each identified by their complex web of virtual neurons and synapses. These neurons are mapped to the tile locations on the game screen which are read through an emulator, and are connected through other neurons and synapses to the potential outputs for crAIg, the buttons on the controller. The life of the crAIgs is short and exciting, if they are not able to continually progress through the level, their genome is deemed inferior and its chance of reproduction slims. Through this process, stronger and more intelligent crAIgs continue to breed with each other, as happens in natural evolution, and eventually, an alpha species can prevail.

How I built it

We build crAIg largely through the Lua scripting language. Lua is an ideal language for interacting with a classic game like Super Mario Bros., as many emulators support interfacing with it. We used an open source emulator called FCEUX to build and test crAIg. The front end for the app was built using a node.js server with Socket.io integration. crAIg periodically saves his status as JSON files which are read by the server, passed to the client through websockets, and displayed to the user through d3. This allows us to better understand crAIg's brain as it gives a visual representation for what he is 'thinking'.

Challenges I ran into

Challenges in this project were frequent and occasionally frustrating. One of the largest issues we ran into was various quirks with the Lua language and the environment which we had to test it through. When we wanted to test crAIg in action, the only way to do so is by running the script through the emulator. Unfortunately, the emulator lacks any script debugging tools outside of a console, making bugfixing a tiresome process. Additionally, FCEUX is very old software, originally published in 2000, causing us to run into memory issues which were difficult to diagnose.

Accomplishments that I'm proud of

While crAIg is unable to clear a full level yet, we are confident he soon will be able to. His progress throughout the level is evident, as each successful iteration he appears smarter and tends to make it further.

What I learned

We learned a significant amount through crAIg's development. Having never had any experience with Lua, both of us are proud to say we have a new language under our belts. We also learned a considerable amount about machine learning and neural networks, knowledge we hope to be able to use in the future.

What's next for crAIg

Share this project:
×

Updates