Back to Home

Pizza Tycoon Traffic Simulation on 25 MHz

The article breaks down the traffic system in Pizza Tycoon 1994, running on 25 MHz. Tile rules, pixel-by-pixel movement and simple collisions ensure efficiency. Pizza Legacy author recreated the mechanics through assembler analysis.

Pizza Tycoon Traffic: how 25 MHz simulate the city
Advertisement 728x90

Traffic Simulation in Pizza Tycoon: Running Smoothly at 25 MHz

In Pizza Tycoon, traffic is handled by a straightforward system that runs on a 386 processor clocked at 25 MHz. Each vehicle moves one pixel per game tick. The main loop checks for obstacles and adjusts coordinates: +1 to X when heading east, -1 to Y when going north.

The progress counter counts down from 16 to 0. When it hits zero, it resets to 16 and triggers tile boundary logic: picking a direction and updating the sprite. 16x16 pixel tiles keep everything in sync—heavy calculations happen 16 times less often than pixel-by-pixel movement.

At spawn, progress is randomized (1–16) to spread the load across frames.

Google AdInline article slot

Road Layout and Direction Rules

Maps are a 160x120 grid of tiles from landsym.vga. Roads are one-way: tile 0x16 goes east, 0x06 goes west, 0x26/0x36 handle vertical paths.

Corners add branching. Tile 0x56 (CORNER_SW) allows west or south. Choice: 50% turn/straight. Banning two left turns in a row keeps things natural.

Maps are designed logically—adjacent tiles always support valid paths.

Google AdInline article slot
  • Straight tiles: Fixed direction.
  • Corners: Probabilistic choice with anti-looping.
  • T/X intersections: Corner combinations.

Collisions via Pairwise Checks

O(n²) for 25 vehicles means 625 checks per frame. Optimization: early exit by direction. East+west pairs bail out without coord checks, since one-way roads prevent head-ons.

Checks:

  • Directions (cuts half the pairs).
  • Lane (same road match).
  • Coordinate math (rare, <10 pairs).

Collision → pause 10 ticks. Jams clear naturally: lead vehicle moves first.

Google AdInline article slot

Bugs (clipping through) are a side effect of optimizations, fine for visual sim.

Vehicle Spawning and Recycling

Entering street mode: scan 132 tiles (12x11). For roads, roll dice based on neighborhood density. Corners excluded.

Exiting screen: replace with new vehicle of opposite direction/color on same tile. Scrolling handles new lanes similarly.

// Spawn pseudocode
for each road_tile in viewport:
  if random(traffic_density) > threshold:
    spawn_car(tile, random_direction, random_progress)

Disassembling Assembly and Modern Pitfalls

The Pizza Legacy author spent 14 years on overkill graphs, A*, and collisions. Original is simpler: tiles dictate paths, no physics/speeds.

Assembly analysis + LLM revealed the mechanics. Restoration: switch in decide_desired_direction (Car.cpp) by tile types.

| Approach | Complexity | Efficiency |

|----------|------------|------------|

| Original | Simple rules | 25 MHz, 30 vehicles |

| Modern | Graphs, physics | Deadlocks on 2010+ CPUs |

Key Takeaways

  • One-way tiles eliminate pathfinding.
  • Early collision exits minimize loops.
  • Pixel-by-pixel movement + infrequent updates = low CPU load.
  • Probabilistic turns + anti-looping = realism without AI.
  • Vehicle recycling skips list management.

— Editorial Team

Advertisement 728x90

Read Next