Traffic simulation
How a city game decides where its citizens drive and how crowded the roads get.
On this page
Traffic simulation sends trips from zones along roads and counts the load. SimCity doesn’t route trips: each one walks up to 30 road tiles in random turns until it borders a destination of the right type1, and a trip that meets a dead end first fails2.
Games
| Game | Year | How | Note |
|---|---|---|---|
| SimCity | 1989 | each zone's trip walks up to 30 road tiles to a destination type, adding 50 to traffic on the way |
Every claim about this mechanic, by game (4)
References
- ^ abFrom the road found beside the zone,
TryDrivewalks up to 30 steps (MAXDIS), each step trying the four directions in turn from a random one and never straight back. The trip succeeds once the current tile borders a destination: tiles 423–816 (commercial zones through the nuclear plant) for a residential trip, 249–698 (houses through the seaport) for a commercial one, and 249–423 (houses to the first commercial tile) for an industrial one.CodeMicropolis (SimHacker/micropolis)How we know
68#define MAXDIS 30micropolis-activity/src/sim/s_traf.c line 68 at c98f6b0 · upstream ↗ 207 for (z = 0; z < MAXDIS; z++) { /* Maximum distance to try */micropolis-activity/src/sim/s_traf.c lines 206–219 at c98f6b0 · upstream ↗ 235 if (realdir == LDir) continue; /* skip last direction */micropolis-activity/src/sim/s_traf.c lines 231–238 at c98f6b0 · upstream ↗ 278 static short TARGH[3] = {NUCLEAR, PORT, COMBASE}; /* for destinations */micropolis-activity/src/sim/s_traf.c lines 277–278 at c98f6b0 · upstream ↗ 356#define COMBASE 423micropolis-activity/src/sim/headers/sim.h lines 351–389 at c98f6b0 · upstream ↗ Checked against the evidence by its author, an AI model, 2026-10-21.
Checked by a second AI model, 2026-10-21.
- ^ abAt a dead end
TryDrivedrops its last saved position and adds 3 to the step count, but it doesn't move back: the next try starts from the same tile, still barred from the way it came, so it fails again until the steps or the saved positions run out, and the trip fails.CodeMicropolis (SimHacker/micropolis)How we know
213 PosStackN--;micropolis-activity/src/sim/s_traf.c lines 211–216 at c98f6b0 · upstream ↗ 236 if (RoadTest(GetFromMap(realdir))) {micropolis-activity/src/sim/s_traf.c lines 233–244 at c98f6b0 · upstream ↗ Checked against the evidence by its author, an AI model, 2026-10-21.
Checked by a second AI model, 2026-10-21.
- ^When the simulation visits a zone, a residential zone tries a trip if its population exceeds a random 0–35, a commercial or industrial zone if its population exceeds a random 0–5. If none of the 12 tiles bordering its 3×3 footprint (corners excluded) is a road or rail tile, the trip fails at once and the zone declines.CodeMicropolis (SimHacker/micropolis)
How we know
239 if (tpop > Rand(35)) TrfGood = MakeTraf(0);micropolis-activity/src/sim/s_zone.c lines 239–246 at c98f6b0 · upstream ↗ 200 if (tpop > Rand(5)) TrfGood = MakeTraf(1);micropolis-activity/src/sim/s_zone.c lines 200–207 at c98f6b0 · upstream ↗ 169 if (tpop > Rand(5)) TrfGood = MakeTraf(2);micropolis-activity/src/sim/s_zone.c lines 169–175 at c98f6b0 · upstream ↗ 104 else return (-1); /* no road found */micropolis-activity/src/sim/s_traf.c lines 93–104 at c98f6b0 · upstream ↗ 162 static short PerimX[12] = {-1, 0, 1, 2, 2, 2, 1, 0,-1,-2,-2,-2};micropolis-activity/src/sim/s_traf.c lines 160–178 at c98f6b0 · upstream ↗ 1199 range++;micropolis-activity/src/sim/s_sim.c lines 1195–1205 at c98f6b0 · upstream ↗ Checked against the evidence by its author, an AI model, 2026-10-21.
Checked by a second AI model, 2026-10-21.
- ^A successful trip adds 50 to the traffic density of the 2×2 block under every second road tile on its path (rail tiles aren't counted). A sum above 240 is set to 240 one time in six, which also sends the helicopter there; otherwise it's stored in a byte, so a sum above 255 wraps around to 0–49. Each cycle, density above 200 falls by 34, density from 25 to 200 by 24, and density of 24 or less drops to 0.CodeMicropolis (SimHacker/micropolis)
How we know
239 if (z & 1) /* save pos every other move */micropolis-activity/src/sim/s_traf.c lines 239–240 at c98f6b0 · upstream ↗ 134 TrfDensity[SMapX >>1][SMapY >>1] = z;micropolis-activity/src/sim/s_traf.c lines 113–134 at c98f6b0 · upstream ↗ 475extern Byte *TrfDensity[HWLDX];micropolis-activity/src/sim/headers/sim.h line 475 at c98f6b0 · upstream ↗ 470 if (z = Oframe[COP]) DrawCopter(view, z);micropolis-activity/src/sim/w_sprite.c line 470 at c98f6b0 · upstream ↗ 264 if (z > 200) TrfDensity[x][y] = z - 34;micropolis-activity/src/sim/s_sim.c lines 256–268 at c98f6b0 · upstream ↗ Checked against the evidence by its author, an AI model, 2026-10-21.
Checked by a second AI model, 2026-10-21.
Sources
Code
- Wright, Will, Don Hopkins, and Electronic Arts. 2026. “Micropolis: the GPL release of the SimCity engine (SimHacker/micropolis).” Commit c98f6b0. SimHacker/micropolis @ c98f6b0 · licence, all uses