Pac-Man ghost AI explained: how each ghost decides where to go

The ghosts have no memory, no pathfinding and no randomness outside frightened mode. They follow one rule at every junction, and once you know the rule you can predict them tile by tile.

Diagram of a neon maze grid with four coloured target markers and vector arrows

The one rule every ghost follows

At each intersection a ghost looks at the tiles it could enter next, excluding the one it came from, and picks the one with the shortest straight-line distance to its current target tile. Ties are broken in the order up, left, down, right. That is the whole decision process. There is no path-finding and no awareness of walls beyond the next tile, which is why ghosts sometimes take a "wrong" turn around a wall: they are minimising distance as the crow flies, not along the corridor. Everything that makes the four ghosts feel different comes from how their target tile is chosen.

Three modes: scatter, chase and frightened

A level runs on a timer that alternates ghosts between scatter (targeting their own corner) and chase (targeting a tile related to Pac-Man). On level 1 the sequence is scatter 7 seconds, chase 20, scatter 7, chase 20, scatter 5, chase 20, scatter 5, then chase forever. From level 5 the scatter phases shrink to 5 seconds and the third chase phase lasts over a thousand seconds, so late levels are effectively permanent chase after the first minute. Every mode change forces all ghosts to reverse direction, a visible cue skilled players watch for.

Frightened mode starts when Pac-Man eats a power pellet. Ghosts reverse, slow down, turn blue and move pseudo-randomly at junctions. The durations by level are in how power pellets work.

Each ghost's target tile

GhostScatter targetChase target
Blinky (red)Top-right cornerPac-Man's current tile
Pinky (pink)Top-left cornerFour tiles ahead of Pac-Man in his facing direction
Inky (cyan)Bottom-right cornerTake the tile two ahead of Pac-Man, draw a vector from Blinky to it, and double that vector
Clyde (orange)Bottom-left cornerPac-Man's tile if more than 8 tiles away; otherwise his scatter corner

The scatter corners sit outside the maze, so a ghost in scatter mode circles the nearest loop to its corner. Names and nicknames are explained in pacman ghost names.

The overflow bug

When Pac-Man faces up, the code that computes "four tiles ahead" also subtracts four tiles on the horizontal axis, because the up direction was stored as a negative value and a 16-bit addition carried into the wrong byte. So Pinky's real target is four up and four left, and Inky's reference tile is two up and two left. The bug survived because testers never noticed, and it is now a defining part of the game: patterns that work on the arcade ROM depend on it, and faithful ports reproduce it deliberately.

Cruise Elroy

Blinky alone changes speed mid-board. On level 1 he moves at 75% of maximum like the other ghosts, rises to 80% when 20 dots remain and to 85% when 10 remain. The thresholds grow on later levels (30 and 15 on level 2, and so on) until he is accelerating with more than a hundred dots left. If Pac-Man dies, Blinky returns to normal speed until Clyde has left the house. The nickname's origin is unknown; it appears in the earliest player communities.

Leaving the ghost house

Blinky begins outside. The others leave according to dot counters: on level 1, Pinky immediately, Inky after 30 dots, Clyde after 60. From level 3 all leave at once. A separate timer releases the next ghost if Pac-Man goes 4 seconds without eating a dot (3 seconds from level 5), which punishes camping.

No-up zones and tunnels

In four specific corridor segments, two above the ghost house and two near Pac-Man's starting position, ghosts cannot choose "up" in scatter or chase mode. Pac-Man can. This creates safe routes that experienced players exploit. Inside the warp tunnels ghosts drop to 40% speed on level 1, so the tunnel is the most reliable escape in the game. The maze geometry is described in pacman maze layout.

Why this design works

Because the ghosts are deterministic, the game rewards learning. Pattern players memorise routes that exploit the exact timers, which is how perfect games are achieved (see how a perfect pacman game works). Casual players feel coordinated pressure without being able to point to unfairness. The drones in the games on the mr pacman arcade hub use the same philosophy, one chaser, one ambusher, one flanker and one wanderer, with randomised mazes so that patterns matter less than reading the board.

Frequently asked questions

Do Pac-Man ghosts use pathfinding?

No. Each ghost simply picks the next tile that is closest in straight-line distance to its target.

Are the ghosts random?

Only in frightened mode. In scatter and chase they are fully deterministic.

Why does Pinky move away when I face up?

The overflow bug shifts her target four tiles to the left as well as up.

How far ahead does Pinky target?

Four tiles in Pac-Man's facing direction (plus four left when he faces up).

What is Cruise Elroy?

The state in which Blinky speeds up when only a few dots remain on the board.