Toru Iwatani’s 1980 masterpiece Pac-Man is widely celebrated for its cheerful aesthetics, but beneath its neon maze lies one of the most brilliant breakthroughs in the history of artificial intelligence. If all four enemy ghosts had simply tracked the player using standard shortest-path algorithms, the game would have been unplayable: the ghosts would have coalesced into a single lethal pack, cornering and killing the player within seconds. Instead, Iwatani engineered four distinct, deterministic Tile-Targeting State Machines, giving each ghost a unique behavioral personality through simple geometric formulas.
In our retro arcade catalog, titles like Retro Maze Man and Retro Pac Maze Escape honor this foundational AI architecture. By deconstructing the mathematical targeting rules of Blinky, Pinky, Inky, and Clyde, players can anticipate enemy vectors, manipulate ghost paths, and master high-level maze routing.
1. Grid Mechanics: The Intersection Decision Engine
The maze is modeled as a discrete $28 \times 36$ tile grid. To understand ghost navigation, one must understand how a ghost selects its direction:
THE INTERSECTION LOOKAHEAD DECISION
Candidate: NORTH (Euclidean d1)
▲
│
Candidate: WEST ◄──── [ INTERSECTION ] ────► Candidate: EAST
(Euclidean d2) │ (Euclidean d3)
│ (Illegal: Cannot reverse SOUTH!)
The Three Movement Constraints:
- Zero Reversal Invariant: A ghost cannot reverse its direction ($180^\circ$ turn) during normal navigation. If a ghost enters an intersection moving East, it can only continue East, turn North, or turn South. It cannot turn back West.
- One-Tile Lookahead Calculation: A ghost decides which turn to take one full tile before it actually enters an intersection.
- Euclidean Distance Minimization: When choosing among available adjacent tiles, the ghost calculates the straight-line Euclidean distance from each candidate tile to its current Target Tile ($T_x, T_y$): $$d = \sqrt{(X_{\text{candidate}} - T_x)^2 + (Y_{\text{candidate}} - T_y)^2}$$ The ghost selects the candidate tile that strictly minimizes $d$. If two options produce identical distances, the engine resolves ties using strict directional priority: Up > Left > Down > Right.
2. Deconstructing the Four Ghost Personalities
Each of the four ghosts possesses a distinct targeting equation, producing emergent psychological behaviors from elementary arithmetic:
THE GHOST TARGETING MATRIX
┌─────────────────────────────────────────────────────────────────────────────┐
│ 1. BLINKY (Red / "Shadow") ──► Target: Pac-Man's exact current tile (X, Y)│
├─────────────────────────────────────────────────────────────────────────────┤
│ 2. PINKY (Pink / "Speedy") ──► Target: 4 tiles ahead of Pac-Man's heading │
├─────────────────────────────────────────────────────────────────────────────┤
│ 3. INKY (Cyan / "Bashful") ──► Target: Doubled vector from Blinky to │
│ intermediate tile ahead of Pac-Man │
├─────────────────────────────────────────────────────────────────────────────┤
│ 4. CLYDE (Orange / "Pokey") ──► Target: If d > 8 tiles, target Pac-Man; │
│ If d <= 8 tiles, flee to corner! │
└─────────────────────────────────────────────────────────────────────────────┘
1. Blinky (Red - Oikake / The Chaser)
Blinky is the primary relentless pursuer. His targeting formula is direct tracking: $$T_{\text{Blinky}} = (X_{\text{PacMan}}, Y_{\text{PacMan}})$$
- Cruise Elroy Mechanic: When the remaining dots in the maze drop below specific thresholds (e.g., 20 dots, then 10 dots), Blinky permanently speeds up, eventually moving faster than Pac-Man even when eating dots.
2. Pinky (Pink - Machibuse / The Ambusher)
Pinky does not chase Pac-Man; she sets an ambush. Her target tile is located 4 tiles ahead of Pac-Man’s current directional heading: $$T_{\text{Pinky}} = (X_p + 4 \cdot \vec{v}_x, Y_p + 4 \cdot \vec{v}_y)$$
- The Up-Overflow Bug: Due to a famous 16-bit register offset in the original Z80 assembly code, when Pac-Man faces UP ($\vec{v} = (0, -1)$), the engine accidentally offsets Pinky’s target 4 tiles up and 4 tiles left, creating a unique diagonal ambush vector.
3. Inky (Cyan - Kimagure / The Flanker)
Inky is the most complex algorithmic agent. His target tile depends on both Pac-Man’s heading and Blinky’s physical position:
- Identify the intermediate reference tile $R$, located 2 tiles ahead of Pac-Man.
- Draw a mathematical vector $\vec{V}$ from Blinky’s current tile to $R$: $$\vec{V} = R - \text{Pos}_{\text{Blinky}}$$
- Double this vector and project it from Blinky’s position: $$T_{\text{Inky}} = \text{Pos}_{\text{Blinky}} + 2 \cdot \vec{V}$$ This mathematical relationship means that if Blinky is close to Pac-Man, Inky attacks aggressively; if Blinky is far away, Inky’s target swings wildly to the opposite side of the maze, creating terrifying pincer movements.
4. Clyde (Orange - Otoboke / The Feigner)
Clyde alternates between aggression and cowardice based on proximity:
- Calculate Euclidean distance $d$ between Clyde and Pac-Man.
- If $d > 8$ tiles: Clyde targets Pac-Man directly ($T_{\text{Clyde}} = \text{Pos}_{\text{PacMan}}$).
- If $d \le 8$ tiles: Clyde panics, abandoning the chase to retreat to his home corner in the bottom-left of the maze ($T_{\text{Clyde}} = (0, 31)$).
CLYDE'S DISTANCE THRESHOLD LOGIC
[Pac-Man]
│
Distance > 8 Tiles? ───► YES: Aggressive Chase (Acts like Blinky)
│
▼ NO (d <= 8)
Cowardly Retreat! ──────► Retreats to Bottom-Left Corner
3. The Global Mode State Machine: Scatter, Chase, and Frightened
The entire ghost fleet operates under a synchronized global timer that cycles between three operational modes:
[START] ──► [SCATTER 1 (7s)] ──► [CHASE 1 (20s)] ──► [SCATTER 2 (7s)] ──► [CHASE 2 (20s)] ──► ...
│ │ │
▼ ▼ ▼
Retreat to Corner Hunt by Rules Retreat to Corner
(Breathing Room) (Pincer Attack) (Breathing Room)
1. Scatter Mode (Periodic Retreat)
During Scatter Mode, all ghosts cease hunting Pac-Man. Their target tiles are reassigned to fixed coordinates outside the four corners of the maze. The ghosts disperse to their respective corners, looping in harmless circles for 5 to 7 seconds. This grants the player predictable windows to clear open corridors.
2. Chase Mode (Active Hunting)
Ghosts re-engage their individual targeting formulas, hunting Pac-Man across the maze. In standard levels, Scatter and Chase alternate four times before the engine locks permanently into endless Chase Mode.
3. Frightened Mode (Power Pellet Eaten)
When Pac-Man eats an energizer, all ghosts instantly reverse direction ($180^\circ$ turn), turn deep blue, and slow down. Their target tiles are chosen using a pseudo-random number generator at every intersection, making their movements erratically defensive.
4. Technical Comparison: Arcade AI Systems and Pathfinding
The following matrix compares artificial intelligence architectures and spatial decision mechanics across classic browser-based arcade titles:
| Game Title | Enemy AI Architecture | Pathfinding Method | Predictability Factor | Primary Evasion Tactic | Portal Title |
|---|---|---|---|---|---|
| Retro Maze Man | Multi-Agent State Machine | Tile-Targeting Euclidean Distance | 100% Deterministic | Corner Looping & Mode Synchronization | Retro Maze Man |
| Pac Maze Escape | Asymmetric Pincer Swarm | Offset Vector Projection | High | Luring Blinky into Scatter Phase | Retro Pac Maze Escape |
| Snake Classic | Self-Avoidance Graph | Greedy Breadth-First Expansion | Low | Hamiltonian Cycle Packing | Snake Classic Retro |
| Sokoban Warehouse | Static Obstacle Collision | A* Forward Crate Pathfinding | Absolute | Deadlock Pre-Calculation | Sokoban Warehouse Puzzle |
| Clumsy Bird | Procedural Obstacle Spawner | Fixed-Velocity Parabolic Barrier | Deterministic | Vertical Tap Rhythm | Clumsy Bird |
5. Exploiting Ghost AI for High-Score Mastery
To dominate maze levels in Retro Maze Man:
- Manipulate Pinky by Shifting Heading: Because Pinky targets 4 tiles ahead of your heading, briefly facing toward a wall shifts Pinky’s ambush target into a dead-end, buying you safe passage across central corridors.
- Never Flee in Clyde’s Direction: If you run toward Clyde, you will cross his 8-tile radius threshold. Clyde will suddenly turn around and flee directly ahead of you into his bottom-left corner, cornering you against Blinky.
- Cross-Train Topological Navigation: Hone your discrete grid navigation across Snake Classic Retro to build rapid cornering instincts.
Frequently Asked Questions
Why do the ghosts reverse direction when entering Scatter Mode?
The $180^\circ$ direction reversal is the engine’s visual signal that a mode change has occurred. Because ghosts are mathematically forbidden from reversing under normal conditions, the game engine artificially forces a $180^\circ$ turn whenever Scatter, Chase, or Frightened modes trigger. Skilled players watch for this sudden reversal to confirm that Scatter mode has begun, signaling it is safe to traverse the center of the board.
What is the “Split Screen” bug at Level 256 in classic Pac-Man?
At Level 256, the 8-bit assembly subroutine that draws the fruit counter overflows: it attempts to draw 256 fruit symbols, exceeding the screen memory limits and corrupting the right half of the maze with garbage characters. This effectively terminates play, making Level 256 the legendary unbeatable “Kill Screen” of arcade history.
Is it possible to find a spot in the maze where ghosts can never find you?
Yes. There is a famous “Safe Spot” located directly to the right and above the ghost house. If Pac-Man enters this coordinate while no ghost is directly observing him and faces UP, the mathematical targeting formulas of all four ghosts will continuously cycle around him without ever designating that specific coordinate as a target, allowing the player to remain safe indefinitely.