# How the Pac-Man ghosts think: the 4 rules

> The Pac-Man ghosts don't think: each one aims at a spot in the maze and, at every intersection, turns toward the side closest to that spot. Red aims at Pac-Man, pink aims ahead of him, blue uses red's position and orange runs off when it gets close. Together, the four rules look like a team.

Summary for when you're short on time

- Pac-Man was released in Japan on May 22, 1980, by Namco, designed by Toru Iwatani, who did not code: he designed the rules and someone else wrote the code.
- Iwatani said in 1986 that the hardest part was the movement of the four ghosts, because he didn't want them chasing the hero in single file.
- Each ghost aims at a small square of the maze and, at every intersection, picks the path closest to that spot in a straight line, never turning back on its own.
- Red aims at Pac-Man himself; pink aims four squares ahead of him; blue uses Pac-Man's position and red's; orange chases from afar and goes back to its corner when it gets within eight squares.
- The attacks come in waves: in the first level, the ghosts scatter to the corners for 7 seconds and chase for 20, four times, and after that they only chase.
- Pink's rule has a programming error: when Pac-Man faces up, the target also moves four squares to the left.
- According to Wikipedia, Guinness recognized Pac-Man as the most successful coin-operated arcade game, with 293,822 machines installed.

Your first step: Think of an enemy in a game you know and write, in one sentence, the rule it follows, the way the red ghost's rule is written: it goes straight to where you are.

By Daniel Novi. Published November 7, 2026. Updated November 7, 2026. Address: https://www.gamearchitectsai.com/en/stories/how-pac-man-ghosts-think

## How do the Pac-Man ghosts decide where to go?

Each ghost picks a target, a small square of the maze, and moves toward it. The maze is divided into squares of 8 by 8 screen pixels, and the only thing that changes from one ghost to another is how it picks that target[1].

The path to the target is the same for all four. Whenever it nears an intersection, the ghost looks at the exits and takes the one closest to the target in a straight line. It only thinks one step ahead, so it sometimes picks the longer way around[1].

There are two restrictions. A ghost never turns back on its own. And when two exits are the same distance away, the order of preference is up, then left, then down[1].

## What is each ghost's rule?

One per ghost, and it fits in a sentence. The English names are Blinky, Pinky, Inky and Clyde; the Japanese nicknames, which appear in the game itself in Japan, describe better what each one does[1].

| Ghost | Japanese nickname | Where it aims when chasing |
|---|---|---|
| Blinky, red | Oikake, "chaser" | The square where Pac-Man is |
| Pinky, pink | Machibuse, "ambusher" | Four squares ahead of Pac-Man |
| Inky, light blue | Kimagure, "whimsical" | A spot calculated from Pac-Man and from red |
| Clyde, orange | Otoboke, "the one who plays dumb" | Pac-Man, when far away; its own corner, when close |

**Red** goes straight to where you are. That's why it almost always comes right behind Pac-Man. At two points in each level, as fewer dots remain, it gets 5% faster and stops giving you a break[1].

**Pink** doesn't even aim at you: it aims four squares ahead of your mouth, to cut you off. Good players use this. If you head toward it, the target ends up behind pink itself, and it turns at the first exit[1].

**Blue** is the only one that looks at another ghost. Its rule takes the spot two squares ahead of Pac-Man, draws a line from red to that spot and doubles its length. When red is far away, blue seems to wander; when red is close, blue shows up too[1].

**Orange** chases just like red while it is more than eight squares away. When it gets closer than that, it switches its target to the bottom-left corner and leaves. The effect is a ghost that comes, gives up and comes back[1].

## Why did Iwatani make four different ghosts?

So the ghosts wouldn't chase the hero in single file. Toru Iwatani, the creator of Pac-Man at Namco, said in 1986 that the hardest part of the game was the algorithm for the four ghosts. An algorithm is the recipe of steps the computer follows. According to him, it was "the heart of the game"[2].

He wanted each ghost to have its own way of moving, because four chasers in single file would make the game tiresome and flat, in his words. In the same interview, he describes red going straight after Pac-Man and another ghost aiming a few dots ahead of his mouth, almost "sandwiching" him[2].

Iwatani also said he was not a programmer. He designed the rules and the parts of the game, and other people wrote the code. According to him, about five people worked on the game, which took a year and five months from idea to stores[2]. Wikipedia mentions Iwatani plus nine other people, and says work began in early 1979[3]. The game came out in Japan on May 22, 1980, under the name Puck Man[3].

## Why do the ghosts attack and then scatter?

Because Iwatani felt that being surrounded all the time would be too stressful for the player. He created the attack in waves: the ghosts attack, retreat, regroup and attack again[2].

In the game, this is a clock. In the first level, the ghosts spend 7 seconds each heading to their own corner of the maze, then 20 seconds chasing. This repeats, with the last two retreats lasting 5 seconds, and after the fourth wave they only chase[1]. In the following levels, the retreats get shorter and almost disappear[1].

Every time the mode changes, the ghosts all turn around at once. It's the only time they do that, and it works as a warning for the player: the retreat has started, or it has ended[1].

## What changes when Pac-Man eats the big pellet?

The ghosts turn dark blue, move more slowly and stop having a target: at every intersection, they choose the turn almost at random. This is when Pac-Man does the hunting[1]. Iwatani described this twist as the chance for the hero to be the hunter as well as the hunted[2].

An eaten ghost doesn't disappear. It goes back to the little house in the middle of the maze and then returns to the hunt. And the fright time shrinks with each level, until it disappears entirely from level 19 on[1].

## Do the Pac-Man ghosts have any bugs?

They have a famous one. When Pac-Man faces up, pink's calculation doesn't aim four squares above him: it aims four up and four to the left. Blue has the same deviation, by two squares[1].

Programmer Don Hodges studied the original code and concluded that, in his opinion, it is a programming error in the way the game stores the "up" direction[4]. Hodges even wrote a corrected version of that code and warned that, with the fix, some routes players had memorized no longer work as before[4].

## Why do the ghosts' rules make Pac-Man so gripping?

Because you can learn each ghost, and whoever learns them escapes better (our take). Chad Birch, who explained these rules in 2010 based on Jamey Pittman's study, says he was able to avoid the ghosts much more easily after understanding them[1].

The rules are short, but together they look like a team: one comes from behind, another cuts in front, a third closes the trap when the first one is near. Nobody planned anything. The trap comes from the four rules meeting[1].

## By the numbers

| Data | Value | Source |
|---|---|---|
| Release in Japan | May 22, 1980 | Wikipedia[3] |
| Time from idea to stores | About a year and five months | Iwatani, 1986[2]; Wikipedia[3] |
| People on the project | About five, according to Iwatani; Iwatani plus nine, according to Wikipedia | Iwatani, 1986[2]; Wikipedia[3] |
| Ghosts | 4, each with a targeting rule | GameInternals, 12/02/2010[1] |
| Dots per level | 240 small and 4 big | GameInternals[1] |
| Waves in the first level | 7 s of retreat and 20 s of attack, twice; then 5 s and 20 s; then 5 s and endless attack | GameInternals[1] |
| Distance at which orange gives up | 8 squares | GameInternals[1] |
| Level at which the big pellet stops frightening | From 19 on | GameInternals[1] |
| Arcade machines installed | 293,822, a Guinness record | Wikipedia[3] |

## What the story of the ghosts shows, and what it doesn't

It shows that an enemy's behavior can be a single sentence, and that four well-chosen sentences look like intelligence (our take). It also shows that the person who decided those sentences was not the one doing the coding.

**The other side.** Pac-Man was made without AI, in 1979 and 1980, by a team at a game company, with a programmer and an engineer. Iwatani didn't code, but he had worked at Namco since 1977 and made games for a living. Calling the ghosts' rule "artificial intelligence" is a habit of the field: it is a fixed rule, written by hand, that looks one step ahead. And the detailed rules here come from fans who studied the game and its code, not from a Namco document; the Japanese nicknames, on the other hand, do appear in the game itself.

## And what does AI do in this part today?

This part is not about Pac-Man, which was made without AI. It's about the work.

In 1980, each ghost rule needed someone who knew how to write the code. Today, people who don't code can describe the game in English and the AI writes the commands, which got the name [vibe coding](/en/guide/what-is-vibe-coding). That doesn't make the work easy: testing whether the enemy turned out fun, fixing and deciding are still up to you.

Knowing the names of things helps. Game makers call this enemy behavior, and asking for "an enemy that aims a little ahead of the player, to cut them off" is much clearer than asking for "a smart enemy" (our take). What the AI doesn't do is choose who hunts and how: that idea still belongs to whoever creates. If you want to start with something the right size, see [what your first game should be](/en/start-here/what-should-your-first-game-be), [what the AI does and what stays with you](/en/start-here/make-a-game-without-coding) and [who created Tetris](/en/stories/who-created-tetris), another game born from a single rule.

## Related questions

### What are the names of the Pac-Man ghosts?

Blinky (red), Pinky (pink), Inky (light blue) and Clyde (orange). In Japan, the nicknames describe how each one behaves: chaser, ambusher, whimsical and the one who plays dumb.

### Do the Pac-Man ghosts have artificial intelligence?

In game language, yes: any rule that moves a computer-controlled character is called AI. But it is a short, fixed rule, written by hand in 1980, that looks only one step ahead. It has nothing to do with the AIs that talk with you today.

### Why does the orange ghost run away?

Because its rule changes with distance. Far from Pac-Man, it chases just like red; within eight squares, it switches its target to the bottom-left corner and leaves.

### What happens when Pac-Man eats the big pellet?

The ghosts turn dark blue, move more slowly and choose each turn almost at random. During that time Pac-Man can eat them, and an eaten ghost goes back to the little house in the middle before returning to the hunt.

### Do the Pac-Man ghosts communicate with each other?

No. Each one calculates its own target alone. The only link is that blue's rule uses red's position, which is why blue tends to show up when red is close.

### Who created Pac-Man?

Toru Iwatani, at Namco. He said in 1986 that he was not a programmer: he designed the rules and the parts of the game, and other people wrote the code. The game took about a year and five months, from idea to stores.

### Can I use rules like these in my game?

Yes, and that is how many enemies still work today: one short rule per enemy. When you ask an AI for a game, describing each enemy's rule this clearly helps the AI build what you imagined, but testing and tweaking are still up to you.

## Sources

1. Chad Birch, GameInternals, "Understanding Pac-Man Ghost Behavior" (12/02/2010; Internet Archive copy): https://web.archive.org/web/2023/https://gameinternals.com/understanding-pac-man-ghost-behavior (accessed October 25, 2026)
2. Susan Lammers, "Programmers at Work" (1986), interview with Toru Iwatani (reproduction): https://www.oocities.org/siliconvalley/heights/5874/iwatani.htm (accessed October 25, 2026)
3. Wikipedia, "Pac-Man": https://en.wikipedia.org/wiki/Pac-Man (accessed October 25, 2026)
4. Don Hodges, "Pac-Man's Ghost Behaviour Analyzed and Fixed" (12/30/2008): http://donhodges.com/pacman_pinky_explanation.htm (accessed October 25, 2026)
