
Wall collision: every time a ghost collides with a wall object, it means it can't move further, and a new direction to move towards is required.This results in actual turning left or right when the monster reaches a corner or any crossing point in any case, the ChangeDirection algorithm doesn't allow a ghost to U-turn back Grid snap: every time a ghost snaps with the grid (which means, every time its position is such that it fits perfectly inside a single grid tile), the function can be called to test the opportunity to change direction.When implemented, this function must be executed when at least one of these two events occur: If chance 1 out of 3 and no collisions upwards: If chance 1 out of 3 and no collisions downwards: If chance 1 out of 3 and no collisions rightwards: If chance 1 out of 3 and no collisions leftwards: Then, a generic ghost AI behavior to change path could be described as follows: function ChangeDirection():

.png)
For each state they took a semi-random route at each junction. Each of the four monsters was either chasing you or running away. Pac-Man relied on a very simple AI technique: a state machine. Pac-Man had definite enemy characters that seemed to conspire against you, moved around the level just as you did, and made life tough. Funge talk right about Pac-Man AI in their book " Artificial Intelligence for Games", paragraph 1.1.2: I don't think the effort of implementing such algorithms is worth, given the simplicity of a game such as Pac-Man. AI is not intelligent, it just acts like it
