Question

I want to play game pacman. There is a problem exists in the moving of the pacman ghosts. How can i move the ghost. I use Random Method but it moves in the same direction up or down or left or right. I want actual theory behind pacman movement

Was it helpful?

Solution

This page has an extremely detailed analysis of Pac-Man with information about the AI of each ghost.

OTHER TIPS

Someone read the Pacman Dossier and wrote up a more brief treatment focused specifically on ghost behavior at http://gameinternals.com/post/2072558330/understanding-pac-man-ghost-behavior

Ghost movement in Pacman is not merely a random one. It's AI, with some graph theory in it. If you want (kind-of) realistic enemies in your games, you'll have to learn a little bit about all these subjects.

I already implemented Pacman in Android. To facilitate my work, I started by using a random algorithm. I.e. on every possibility where the ghost can change its direction, one of the available directions is chosen automatically. This isn't too difficult to implement. But with this algorithm, the pacman has an easy life, because the ghosts aren't really hunting pacman.

So in a second approach i read this source: pacmandossier

There you can see that every ghost has a different behaviour. I didn't really implement an exact copy of the behavior there, but instead I used an approximation. On every possible direction change: I calculated the "best direction" by using the smallest Manhattan Distance between the positition of the Pacman and the possible directions the ghost have. Then I do model the varying "aggressivity" of the different ghosts, I used a probability for each ghost to choose the "best direction" versus a random one.

This isn't really the original algorithm, but I think it's quite a good approximation since you can easily see while playing that the ghost more or less try to hunt Pacman.

Naturally you can expand this algorithms, e.g. by using different possibilities and speeds if the ghosts are hunted instead of chasing Pacman.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top