How Ghost AI Works in Pac-Man (Patterns & Behavior)

Veronica Avatar
How Ghost AI Works in Pac-Man (Patterns & Behavior)

At first glance, Pac-Man looks like a simple chase game: four colorful ghosts roam a maze while you, the player, gobble dots and try not to get caught.
But beneath the cheerful graphics lies one of the most brilliantly designed AI systems in gaming history – one that’s predictable enough to be fair, yet complex enough to keep players on edge even four decades later.

The ghosts – Blinky, Pinky, Inky, and Clyde – don’t move randomly. Each follows a distinct personality and algorithm, carefully engineered by Pac-Man’s creator, Toru Iwatani, and Namco programmer Toshio Kai, in 1980.

In this article, you’ll learn exactly how each ghost thinks, how their behavior changes mid-game, and how players can use these patterns to their advantage.

Meet the Ghosts: Personalities with a Purpose

Each of Pac-Man’s four ghost enemies has its own “personality.” This wasn’t just for storytelling – it’s part of their AI logic.

GhostColorJapanese Name (Meaning)English NamePersonality / Behavior
赤いお化け (Aka Oni)RedOikake (“Chaser”)BlinkyAggressive pursuit of Pac-Man
ピンクのお化け (Pinku Oni)PinkMachibuse (“Ambusher”)PinkyTries to position ahead of Pac-Man
水色のお化け (Mizuiro Oni)CyanKimagure (“Fickle”)InkyUnpredictable; uses a vector formula based on Pac-Man and Blinky
オレンジのお化け (Orenji Oni)OrangeOtoboke (“Feigned Ignorance”)ClydeAlternates between chasing and wandering

These personalities were intentionally coded to make players feel like the ghosts had emotions and strategies – even though everything they do follows mathematical logic.

How the Ghost AI System Works

Pac-Man’s ghost AI operates on a finite state machine – meaning each ghost switches between different behavior modes depending on time and game events.

The four core modes are:

  1. Chase Mode – Ghosts actively target Pac-Man using individual algorithms.
  2. Scatter Mode – Each ghost retreats to a specific corner of the maze.
  3. Frightened Mode – Triggered when Pac-Man eats a Power Pellet; ghosts turn blue and move semi-randomly.
  4. Eaten Mode – When eaten by Pac-Man, a ghost’s eyes return to the ghost house to regenerate.

State Transitions

Ghosts don’t stay in one mode forever. The game alternates between Chase and Scatter several times per level.

Level SegmentScatter DurationChase Duration
1st cycle7 seconds20 seconds
2nd cycle7 seconds20 seconds
3rd cycle5 seconds20 seconds
4th cycle onwardForever chase

After the fourth cycle, ghosts remain in permanent pursuit, which is why later levels feel relentless.

Understanding the Maze Grid Logic

The Pac-Man maze is divided into a 28×31 grid, and each tile has coordinates. The ghosts move one tile at a time, recalculating their direction whenever they reach an intersection.

At each intersection, a ghost chooses one of the possible directions (up, down, left, right) based on its target tile – the grid coordinate it’s trying to reach.

Target Tile = AI Objective

  • In Chase Mode, each ghost’s target tile depends on Pac-Man’s position and direction.
  • In Scatter Mode, the target tile is fixed (e.g., Blinky always heads for the top-right corner).

Ghosts cannot reverse direction unless switching modes – this adds predictability for skilled players to exploit.

Individual Ghost Behavior Explaine

Blinky – “The Chaser”

Blinky (red) is the most straightforward and aggressive.
He targets Pac-Man’s current tile directly, moving at the same or slightly higher speed.
As levels progress, his speed increases – earning him the nickname “Cruise Elroy.”

Cruise Elroy Mode

When a certain number of pellets remain:

  • Blinky’s speed increases.
  • He no longer alternates between chase/scatter.
  • He directly hunts Pac-Man continuously.

This design makes the game tenser as you near maze completion – your main hunter literally speeds up the closer you get to victory.

Inky – “The Wild Card”

Inky (cyan) is the most complex – his target tile depends on both Pac-Man and Blinky.

The algorithm:

  1. Take a point two tiles ahead of Pac-Man’s current direction.
  2. Draw a vector from Blinky’s position to that point.
  3. Double that vector — the end point becomes Inky’s target tile.

This means Inky’s behavior depends on Blinky’s proximity. When Blinky is far, Inky may act timid; when Blinky is close, he joins the pursuit from unexpected angles.

In practice, Inky’s unpredictability adds chaos to the maze – you can’t memorize his pattern easily.

Clyde – “The Drifter”

Clyde (orange) alternates between chasing Pac-Man and wandering.

His rule:

  • If more than 8 tiles away, he behaves like Blinky (targets Pac-Man).
  • If within 8 tiles, he retreats to his corner.

Clyde’s back-and-forth pattern can lure players into traps.
While he seems less aggressive, his unpredictability often ruins “safe patterns” during longer games.

Ghost Movement Priorities

When a ghost reaches an intersection, it evaluates all possible directions (except reversing). It chooses the path that minimizes the Euclidean distance between its next tile and its target tile.

Priority order:

  1. Up
  2. Left
  3. Down
  4. Right

This subtle bias affects how ghosts behave in certain junctions – for example, Blinky often approaches from above when multiple paths are available.

Speed and Behavior by Level

Ghost and Pac-Man speeds change as levels increase:

LevelPac-Man SpeedGhost SpeedFrightened Duration
180%75%6 seconds
590%85%3 seconds
9100%95%1 second
21+90%95%0 seconds (no blue mode)

By Level 21, Power Pellets no longer turn ghosts blue – the “Frightened” state disappears, making perfect pattern play essential.

How “Patterns” Work – And Why They Matter

Early players discovered that Pac-Man’s AI, though clever, is still deterministic. Since ghosts follow fixed movement logic, players could design movement “patterns” that guarantee safety and maximum points.

Examples:

  • Cherry Pattern (Level 1): guides Pac-Man through a predictable route.
  • Mid-Fruit Pattern: optimized for clearing pellets near ghosts safely.
  • Apple Pattern: used in advanced play for near-perfect runs.

However, later versions (like Ms. Pac-Man) added randomness to ghost movement – eliminating perfect pattern looping.

Why the AI Feels “Human”

Toru Iwatani designed the ghosts not just to chase Pac-Man, but to convey emotion:

  • Blinky feels like anger (direct pursuit).
  • Pinky feels cunning (ambush).
  • Inky feels nervous (hesitant).
  • Clyde feels lazy (unpredictable).

This emotional illusion – achieved with only a few lines of code – made Pac-Man feel alive.
It’s a prime example of early procedural personality design in gaming.

Exploiting Ghost Behavior: Pro Tips

For serious players aiming for high scores:

  1. Memorize Scatter Timing
    Learn when ghosts retreat; use those seconds to clear risky pellets.
  2. Corner Awareness
    Pinky loves to camp corners – approach from diagonals when possible.
  3. Track Blinky’s “Elroy” Mode
    When pellets are nearly gone, shift routes to avoid straight chases.
  4. Use Tunnels Strategically
    Ghosts slow down by ~40% in tunnels; use them for quick escapes.
  5. Leverage Frightened Mode
    Eat ghosts for points but focus on pellet clearing during blue-time transitions.

Pac-Man’s ghost AI remains a marvel of early game design – a perfect blend of logic, psychology, and illusion.

Each ghost acts differently, but together they form a dynamic ecosystem that keeps players challenged without needing randomness.
That’s why even after 40 years, studying their patterns is still fascinating.

So next time you play, remember: Every move you make, every turn you take – the ghosts are calculating.