Urban Traffic Flow: Signal Timing & Congestion Lab (2D)
2D city-grid traffic lab: a real Nagel-Schreckenberg cellular-automaton model runs on a grid of one-way streets with synchronized traffic signals, so you can tune density, speed limit, driver caution and signal-split live and watch congestion form and dissolve, with a live flow-density readout tracking q = k·v̄.
The 3D original renders a static, randomly-generated skyline whose "traffic density" and "population" sliders were cosmetic — they relabelled a stat box without touching the scene. This 2D companion replaces that decoration with the mechanism the title actually promises: a grid of one-way streets, each governed by the Nagel-Schreckenberg cellular automaton (the standard discrete traffic model used in transportation engineering), with synchronized signals at every intersection. Raise the density slider and free-flowing green dots start bunching into red, stationary jams exactly the way real congestion forms behind a bottleneck; widen the signal green-split for one direction and you can watch its cross-streets back up in response — the same trade-off traffic engineers tune when they retime a corridor.
2D urban traffic-flow lab: a Nagel-Schreckenberg cellular automaton (acceleration, gap-limited braking, random slowdown, motion) run per-lane across a synchronized-signal street grid, with a live q = k·v̄ flow-density readout.
2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install
The Nagel-Schreckenberg cellular automaton: each vehicle occupies a discrete cell on a ring-shaped street and every step applies four rules in order — accelerate toward the speed limit, brake to keep a safe gap from the car (or red light) ahead, randomly lose a notch of speed with some probability to model driver hesitation, then move. It is the textbook minimal model that reproduces real highway phenomena like spontaneous jam formation from pure density, with no accident or bottleneck required.
Past a critical density, the random-braking rule occasionally forces a car to slow below what the gap ahead requires; the car behind then has to brake harder, amplifying the disturbance backward through the line. This "phantom jam" effect — a wave of braking with no cause at its origin — is a well-documented, measured real-world phenomenon, and it is exactly what the automaton reproduces.
Every intersection in the grid shares one synchronized clock. Horizontal streets get a green phase for a configurable fraction of the cycle (the Signal Green Split slider); vertical streets get the remainder. A vehicle within range of a red light treats it exactly like a stopped car — the same gap-limited braking rule applies, so the light naturally creates a queue that dissipates once it turns green.
Average speed converts the automaton's cells/step into km/h using an assumed 7.5 m cell length. Flow (q) is the classic traffic-engineering relation q = k·v̄ — density (vehicles per cell) times mean speed — reported as vehicles/minute crossing the network. Congestion is simply the share of vehicles currently at zero velocity.