Four pursuers, one kernel: the maze-chase that reads a street map
The four ghosts are four target functions over one greedy kernel — the same argument a planner makes reading a street network for chokepoints.
Jamey Pittman’s Pac-Man Dossier (revision 1.0.27, 11 August 2015) states the thing almost nobody notices: “Itawani’s team created the illusion of complex pathfinding by using very simple logic and very little code” [sic]. The four pursuers in a maze-chase are not four difficulty settings. They are four different target functions running over one shared movement kernel with about a tile of lookahead — no A*, no BFS, no map, no memory. That distinction is the whole toy.
←TODAY: the sketch runs in the browser now and downloads to a single self-contained page. →3012: the city that survives is the one whose residents read its chokepoints as easily as they read a game. Fulcrum: a pursuit policy and a permeability audit are the same argument about a graph, seen from two ends.
On entering a tile, each pursuer looks one tile beyond the upcoming intersection in every legal direction, throws out the reversal and any wall, and takes whichever test tile sits closest to its own target. Ties break up, left, down, right. Same kernel four times — only the target changes: one aims at the runner’s tile; one four tiles ahead (and four left too when the runner faces up — an honest overflow bug); one doubles the vector from the direct chaser through a point two tiles ahead (a two-body reflection, not “the opposite” of anything); one switches on Euclidean distance, peeling to a corner when close.
That corner is the lesson. Each pursuer’s scatter target is a fixed tile parked in dead space outside the maze, somewhere it can never reach — so the famous “favourite corner” is emergent behaviour from an unreachable attractor, nothing more. (Bandai Namco’s own credit line reads Planning — Tōru Iwatani, Programming — Shigeo Funaki, Sound — Toshio Kai; Pittman notes he could not name the full Namco team and asks readers for sources.)
Here the toy becomes a plan. The cop-number literature maps onto shapes a planner already knows: a cul-de-sac tree needs one pursuer, a rectangular grid two, a wrapping torus three — and Aigner & Fromme proved in 1984 that three suffice for any connected planar graph. The game ships four, so the honest read is “deliberately over-provisioned”, never “the ghosts are dumb”. Two cautions travel with it: a real street map is not planar (Geoff Boeing’s own method uses nonplanar directed multigraphs — bridges and tunnels), and cop-number theorems assume perfect information and optimal play, so they bound what a graph permits and grade nobody’s engineering.
The sketch draws a real street network in top view, an original runner and four original pursuers, and the four targets over that one greedy kernel — with the unreachable scatter targets drawn where they actually sit off the network, because seeing them is the point. A live panel reads node degree, dead-end share, circuity, betweenness as line weight, the worst chokepoint, and a cop-number strip. The network is editable, and a DOM table mirrors the canvas so it stays legible without pixels (MDN’s own advice). Touch it in order:
- Watch the direct and ambush pursuers diverge on the same street.
- Turn on the scatter targets and watch the corner loops appear out of nothing.
- Close the worst chokepoint and read the Gini and the capture time move together.
- Open a cut-through in a cul-de-sac and watch the cop-number strip step from one to two.
Now break it: give two pursuers the same target and the conga line returns. Iwatani said it himself in 2020 — “If all four ghosts had been programmed with the same algorithm, constantly chasing Pac-Man’s current position, they would have formed a conga line, lacking any thrill.” The thrill was never the AI; it was the four policies disagreeing.
Atelier: stop arguing permeability off the plan image and read it as a number the same afternoon. Load Boeing’s indicators (Harvard Dataverse, CC0) for the Zurich urban area — 187 km², 689,208 residents — and look at the line that lands: the single highest-betweenness node lies on 16.43% of all shortest paths, Gini 0.770, against Paris at 0.0695 and Basel at 0.2447. Keep the vocabulary straight, because inverting it is the field’s most common error: integration is closeness predicting to-movement, choice is betweenness predicting through-movement, and the pursuers are a betweenness argument. Bill Hillier and Ozlem Sahbaz’s own calibration is the honest frame, health warning included — “Residential areas should be permeable enough to allow movement in all directions but no more.” Monday move: pull your quartier’s betweenness distribution and mark the top node before you draw a line of the next masterplan.
Hack: Read the whole pursuit brain — it fits in five lines of JavaScript. Collect the legal test tiles, drop the reversal, take the argmin on squared distance to the target, break ties up/left/down/right. Change one variable, target, and you have all four personalities.
const legal = neighbours(tile).filter(t => !t.wall && t.dir !== reverse(dir));
const dist = t => (t.x - target.x) ** 2 + (t.y - target.y) ** 2;
const order = { up: 0, left: 1, down: 2, right: 3 };
legal.sort((a, b) => dist(a) - dist(b) || order[a.dir] - order[b.dir]);
const next = legal[0]; // greedy, one tile of lookahead — no map, no memory
Now build with it: this has been done at least six times — twice by Google, once as a licensed Bandai Namco title. Frank Lantz’s NYU ITP class shipped Pac-Manhattan in 2004, GPS-free by deliberate choice; Human Pacman (Cheok et al.) arrived the same year. We looked and did not find the game-AI and space-syntax literatures reading each other — a gap we noticed, not a boast. Original characters over a real street network is the safe inverse of the 1982 K.C. Munchkin case, where the maze was already changed and the copy still lost — on its characters. Build it, break it, then read your own city’s worst node.
PAZ Kaffi · multidisciplinary editorial, led by PAZ Academy