divillysausages.com

AI Pacman Controller

The AI controller for Pacman was for part of the Games Programming and AI module, which I did in the second semester at Hull. The idea was to make Pacman smart and be able to beat the game and live. Or cheat doing it.

The Brief

T'was quite simple. Create an AI controller that would allow Pacman to eat all the pills and still be alive. Bonus marks for pwning at high scores.

The more controllers you did, the more marks you got. I only did one, but it did rock so I didn't need to do another. Deceptively simple is what I believe in.

The Finished Version

The finished version works surprisingly well. I was looking at success rates of between 70 and 90%. I even racked up 14 consecutive clear runs, which was nice.

The general premise behind my thinking was to keep it as simple as possible. No state machines, fuzzy logic, neural nets, or anything to that effect. I wanted my Pacman to constantly be trying to eat all the dots and not waste time running away.

I settled on a A* / MiniMax hybrid engine. I'd first run an A* from all the ghosts to Pacman's position. This represents the worst possible moves for Pacman. These cells were then penalized depending on how close to the ghost they were. I then did an A* for Pacman to find the best path with the most value, less chance of dying. And that's pretty much it. It's explained in more detail in the report (15Kb), which you can read at your leisure.

I also uploaded a few images of Pacman in action, as well as one movie clip of me winning. I could have put more if I thought anyone would watch them to compare the differences.

The actual program was written by someone else at the university, so all I had to do was the AI. You can download the release version (58Kb) to play with if you want - set the control variable to 0 in the data text file to play as yourself. You can also even download the source (39Kb), or at least all of the source that had to do with me. You probably won't be able to compile it as you probably won't have GXBase, because I'm not entirely sure if we're allowed to give it out or not, it's something I have to check.

Comments

Submit a comment

* indicates required