View Full Version : Help with a Pac-man AI
Mage of Hell
February 6th, 2007, 12:42 PM
Well I'm new to these forums and pretty new to game programming and AI, and me and a friend were working on recreating Pac-man for practice, but we just can't figure out a way to make the ghosts find the player and chase him. The only solution we have thought of is a random movement after a predetermined path to the corners of the board(there are four ghosts). This worked kind of, but we really wanted to go all out and make it just like the original. So if anybody has any ideas on how to create an AI to find the shortest path to the player(taking into account walls), it would really help me out.
Thanks.
SacrificialLamb
February 6th, 2007, 02:21 PM
you could look up A* (http://www.policyalmanac.org/games/aStarTutorial.htm) (there is some flash code for the on this forum) path finding but I doubt that pac man way using path finding I think they would have used some thing simpler that just got the ghosts moving in roundabout the right way.
defx = pac._x- ghosts._x
defy = pac._y- ghosts._y
theta = Math.atan2(defy, defx)
then use the angle " theta"(note it's in radians) to work out what turn the ghosts might want to take. But they would all so have to be able to know if they are stuck and ignore that dater and find another way
B L U E
February 6th, 2007, 05:59 PM
dunno if this will help or not
http://www.kirupa.com/forum/showthread.php?t=243812
Nich
February 6th, 2007, 06:00 PM
Hmm, there was a very specific way the ghosts followed pacman. I'll do a search, and post the link if I can find it.
You shouldn't need A* since the paths the ghosts can take are fixed. The level doesn't change shapes. A series of waypoints will do the trick, though how you set that up would depend on how your map is made (art vs tile based)
Edit: http://en.wikipedia.org/wiki/Pacman#Behavior
Mage of Hell
February 8th, 2007, 07:10 PM
Thanks for the great help guys. Its a work in the making! :P
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.