Traffic Flow Simulator

Run a seeded traffic experiment on a one-lane loop.

Change the number of cars, maximum speed, and driver variation, then watch a phantom traffic jam form and move backward through the traffic.

Last updatedHow we build & check our tools
%
Results will appear here once you enter your values.

The surprise: a jam can form on a clear road

A line of cars can create its own traffic jam. Nobody needs to crash, merge, enter a tunnel, or reach roadworks. The necessary ingredients are close spacing and small changes in speed. One driver eases off, the next driver has slightly less room and slows more, and the response passes from car to car. At low density the disturbance fades. At higher density there is not enough spare road to absorb it, so the disturbance grows into a stop-and-go wave.

This is not only a computer effect. In a published 2008 experiment, 22 drivers began evenly spaced on a 230 metre circular road and tried to hold a steady speed. Small differences in their motion grew until several cars stopped. The resulting jam travelled backward around the circuit even though the lane had no bottleneck. The experiment made the collective cause visible: each driver reacted only to the car ahead, but the whole group produced a new pattern.

The Phantom jam preset recreates that idea in model units. The loop is uniform, the slow zone is off, and the cars begin evenly spaced. Red cars still appear. That is the useful surprise to ask students to explain.

The four rules behind the simulation

The simulator uses the Nagel-Schreckenberg model, introduced in 1992 to study single-lane traffic. The road is split into cells. A cell is empty or holds one car, and each car has a whole-number speed. During one step, every car follows four rules in the same order.

  1. Accelerate: add one cell per step to the current speed, without passing the chosen maximum.
  2. Keep a safe gap: if the car ahead is too close, reduce speed enough that its occupied cell will not be reached.
  3. Dawdle: with the chosen driver-variation probability, reduce speed by one more cell. This stands in for small human differences rather than a planned stop.
  4. Move together: update every position at once. No car sees a half-updated road.

The simplicity is the point. A stop-and-go wave does not have to be programmed as a special event. It emerges from many cars applying the same local rules. Setting driver variation to 0% removes the small disturbances; lowering density gives disturbances more empty road in which to disappear.

How the space-time diagram reveals a backward wave

A road picture shows where cars are now. A space-time diagram shows how their positions change, which is what proves the jam is moving. Read position from left to right and time from top to bottom. Each coloured mark is one car at one step: blue for moving, orange for slow, and red for stopped.

  • A car moves down and right. As time passes, its position number increases. At position 160 it wraps to 0 because the road is a loop.
  • A stationary car makes a nearly vertical trace. Its position changes little while time continues downward.
  • A jam makes a band that moves down and left. Different cars stop in turn at positions farther back along the road. The band is the pattern, not one particular car.

This distinction is the central lesson. Cars are objects; the jam is a travelling pattern. Ocean waves provide a useful comparison: the wave crosses the water even though one parcel of water does not travel with it from one shore to the other.

Classroom investigations with one controlled change

The seed makes fair comparisons possible. Keep it fixed, change one control, jump to the same step, and record average speed, throughput, and density. The printed observation sheet gives students a graph and space to explain the result; the separate answer key keeps the mechanism clear for marking.

  • Find a density threshold: begin with 20 cars and add four at a time. Record the first car count at which a lasting red band appears. Repeat with a second seed and discuss why the exact threshold can vary.
  • Test driver consistency: hold 36 cars and maximum speed 5, then compare 0%, 10%, 20%, and 30% variation. Ask whether more variation changes only the number of slowdowns or also their ability to grow.
  • Compare causes: run the open loop, then switch on the slow zone without changing anything else. Identify what stays the same about the backwards-moving queue and what changes about where it begins.
  • Measure flow, not just speed: throughput counts cars crossing one point per step. A crowded road can hold more cars yet carry fewer past the counter because their speeds collapse. This is why density, speed, and flow should be read together.

Treat cells and steps as abstract units. The model is strong evidence for a mechanism, not a travel-time forecast for a real motorway or street.

Frequently Asked Questions

Common questions about the Traffic Flow Simulator

A phantom traffic jam is a stop-and-go queue with no crash, traffic light, lane closure, or other fixed obstruction. When cars are close enough together, one small slowdown can force the next driver to brake, then the driver behind that one. The disturbance grows into a group of slow or stopped cars even though the road itself is clear. Use the Phantom jam preset with the slow zone switched off to see it happen.