City Traffic Grid
Scale a single jam up to a whole city: cars drive on a grid of two-way streets, obey traffic lights at every intersection and turn at random toward their destinations. Each car keeps a safe gap from the one ahead, brakes for red lights and accelerates when the road is clear, so congestion emerges from thousands of these local decisions. Turn up the number of cars and the network slides from free flow into stop-and-go waves and finally gridlock, where a ring of cars each block the next around a loop of intersections. Tune the traffic-light timing and the car density and watch the average speed and the throughput of the grid respond, finding the density at which flow is highest just before it collapses.
Runs 100% in your browser — simulations are computed locally on your device.
Read the full guide to this tool
Notes
- Traffic flow (cars per minute past a point) is density times speed: it rises as you add cars, peaks at a critical density, then falls as crowding drags speed down — the fundamental diagram of traffic.
- Stop-and-go waves travel backward through a line of cars: each driver brakes a moment after the one ahead, so a disturbance ripples upstream even as the cars themselves move forward.
- Gridlock is a deadlock: cars stopped in an intersection block the cross traffic, which blocks the next intersection, forming a cycle no one can clear — which is why "don’t block the box" rules exist.
- Runs 100% in your browser — simulations are computed locally on your device.