Play n Tools

Free tools & games for everyone

Free · No sign-up · No accounts

Traffic flow simulator

Watch traffic jams appear from nowhere on a ring road, add a traffic light, and find the density that lets the most cars through.

moving   slow   stopped

Average speed
Cars stopped now
Flow past a point

Space-time diagram

Each row is one second (newest at the bottom); each dot is a car along the road. Jams show as red stripes that drift backwards, against the traffic.

Flow against density

Runs the road with 3 to 117 cars using your speed limit, dawdling and light settings.

How to use

  1. Press Play. Cars drive clockwise round a 900 m ring road; colour shows their speed.
  2. Move Traffic up. Past about 20 cars per km, jams appear from nowhere: one slow driver makes the next brake harder, and so on.
  3. Press Make one driver brake and watch a “phantom jam” move backwards in the space-time diagram long after the driver has gone.
  4. Turn on the traffic light and change the green and red times to see queues build and clear.
  5. Press Measure all densities to draw the fundamental diagram: how many cars per hour get through at each density.

Keyboard and touch

TabMove between buttons and sliders
← →Change a slider
Space / EnterPress the focused button (Play, Step…)

Tips

  • With no dawdling (0%), traffic flows smoothly until the road is nearly full: random slowdowns are what create the jams.
  • The fastest flow happens at a fairly low density. That is why some motorways use variable speed limits and ramp lights to keep density below the jam point.
  • A jam’s back end moves backwards at roughly 15 km/h, the same whatever caused it, as on real roads.
  • A lower speed limit can let almost as many cars through with fewer stop-and-go waves.

About this simulator

It uses the Nagel–Schreckenberg model (Kai Nagel and Michael Schreckenberg, 1992). The road is split into 120 cells of 7.5 m. Every second each car speeds up by one step (up to the limit), slows down to the gap in front, slows by one more with the “dawdling” probability, and then all cars move together. Speed 5 is 135 km/h; each step is 27 km/h.

The tests check that cars never collide or overtake, that no car runs a red light, that random runs are repeatable, and that with no dawdling the flow matches the exact result: the smaller of density × speed limit and 1 − density.

It is a simple single-lane model for learning, not a traffic engineering tool. Everything runs on your device.

See you tomorrow!

A fresh daily puzzle every morning, and new tools added every month.

Browse every product