Click.
Bam!
BOOM💥
START

The First AI Personalities

Pac-Man was the first game to feature AI enemies with distinct personalities. Designer Toru Iwatani didn't accomplish this with complex behavior trees or state machines—he simply gave each ghost a completely different mathematical target to pursue.

Four Algorithms, Four Behaviors

The canvas visually maps exactly where every ghost is aiming right now:

  • Blinky (Red) - Direct Chase: Targets the exact tile Pac-Man is currently on. A relentless pursuer.
  • Pinky (Pink) - The Flanker: Aims for the tile 4 steps directly ahead of Pac-Man, cutting him off.
  • Inky (Cyan) - The Tactician: His target is calculated by drawing a line from Blinky, through the space 2 tiles ahead of Pac-Man, and doubling the distance. If Blinky is far away, Inky's flank expands!
  • Clyde (Orange) - The Coward: Pursues Pac-Man until he gets within an 8-tile radius, at which point his algorithm suddenly flips to target his corner retreat. He effectively orbits the player.

The Invisible Phase Timer

All ghosts operate on a global timer alternating between CHASE and SCATTER modes. When Scatter begins, every ghost abandons Pac-Man and heads to their designated corner. Crucially, any time the phase switches, all ghosts immediately reverse direction. This rhythmic breathing mechanism is the secret to Pac-Man's pacing—giving players a brief, invisible reprieve.

Code Snippet

RELATED GAMES