Tom Murphy’s “Playfun” uses AI to play Super Mario Bros

all rights to owner

Tom Murphy, a PhD computer science researcher, has made an AI that will play the likes of Super Mario Bros, Tetris, Karate Kid and Hudson’s Adventure Island (whatever that is). Scrolling through the “Gaming” reader on WordPress I found a blogger who posted something about this unique development but really didn’t do in-depth justice to the subject. No videos of the AI playing and no external links to where they got their info. However, I’m not here to point fingers – I’m here to do a better job than that site.

To start, I like the way Ars Technica puts the idea of Playfun, “Have you ever made the game beat itself?”

According to a website called GeekOSystem Murphy plays the game himself for a while to create a blueprint of possibilities the AI can use and teach it the goals of the game. “It learns what his goals are while he’s playing the game — stomping on a goomba, getting a higher score, getting to a new level, or just not falling down a bottomless hole — and then works out the best ways to achieve those goals,” wrote Ian Chant the GeekOSystem reporter. Even if Murphy doesn’t play the entire game or level, the AI can pick up on cues and play on much farther than Murphy originally did.

For right now “Playfun” is only playing NES games and it doesn’t do a very good job at most of them. It was best at right sliding games like Super Mario and the Adventure Island game. It also played Bubble Bobble (another game I’ve never heard about) very well. Tetris on the other hand was a disaster. It would simply stack blocks because it gets 3 points or something for putting blocks on top of one another. Murphy kept using the word “greedy” to describe it. When the AI learned coins on Mario, it tried to get every coin possible. When Mario grew with the mushroom, it tried to break as many blocks as possible. The AI is even a sore loser and when it realized it had lost Tetris, it just paused the game and never allowed itself to lose.

It is strange to watch the Playfun play. It’s like I was getting angry that it didn’t really care to get all the ?-boxes or shoot the turtle shell. Those are the best parts! It will occasionally hit the ?-boxes just at random and once, the invincibility star came out and Playfun just ran right along. I was almost happy it fell in the bottomless pit after that.

The Ars Technica article that I linked a little earlier goes into the math of the Playfun. Murphy programmed the AI with something called “Lexicographic” ordering. “Lexicographic ordering is a pretty simple mathematical technique used to determine the best order a set of values should come in. It’s most commonly used in libraries or dictionaries for arranging books and words, for instance, with the alphabet determining the order of the letters,” writes Ian Steadman. The algorithm that takes into account all of Murphy’s moves is the Learnfun. The Playfun then takes everything that Learnfun has “learned” and uses it to play. Steadman continues saying, “[it] uses the knowledge from LearnFun to try and increase the values it knows it has to increase—Mario’s score, and how far scrolled to the right Mario is in the level.”

Below is a video of Playfun that Murphy made. I have it embedded to start at 7:47 but if it doesn’t work, just skip to that time to see Playfun play. Go ahead and watch it, but it is way more fun to see what the hell the AI does.

I really love finding cool and interesting technology like the Playfun.

Leave a comment