← Back to Labs

Traffic Flow — Nagel-Schreckenberg Model

Cars: 100
Avg speed: 0.0
Flow: 0.0 cars/cell/step
Jams: 0
Step: 0

Nagel-Schreckenberg Cellular Automaton (1992)

Each cell on a circular road is either empty or contains a car with velocity v ∈ {0,…,v_max}. Each time step applies four rules simultaneously to all cars:


1. Accelerate: v ← min(v+1, v_max)
2. Brake: v ← min(v, gap-1)
3. Randomize: v ← max(v-1, 0) with prob p
4. Move: x ← x + v

The random braking (p > 0) is the key: it spontaneously creates phantom traffic jams — backward-propagating waves with no accident. The space-time diagram (below road) shows car positions over time: diagonal streaks = free flow; vertical/backward-slanted bands = jams. The fundamental diagram (flow vs. density) shows a capacity drop at a critical density ρ_c ≈ 1/(v_max+1).