Traffic Jam Simulator
The Nagel–Schreckenberg model is a cellular automaton that reproduces real highway traffic from four simple rules applied to every car each tick: accelerate, brake to avoid the car ahead, randomly dawdle with probability p, then move. Cars drive around a one-lane ring road, so no one enters or leaves. Drag the density, the maximum speed and the dawdle probability, and the simulator animates the ring with cars coloured by speed while a space-time diagram scrolls underneath — the dark backward-moving stripes are jams. The average flow (throughput) is reported live so you can find the density that maximises it.
Runs 100% in your browser — simulations are computed locally on your device.
Read the full guide to this tool
Notes
- Rules per step: speed up by one (to the limit), slow to the gap ahead, with probability p drop speed by one, then advance. The random dawdle is the only source of noise.
- Above a critical density, jams appear spontaneously with no accident or bottleneck — a single random brake tap propagates backward into a standing wave.
- Flow rises with density until the critical point, then collapses: more cars past that point means less throughput, the fundamental diagram of traffic.
- Runs 100% in your browser — simulations are computed locally on your device.