Every car follows the car in front of it using a simplified car-following model: it accelerates toward a desired cruising speed, but brakes to keep a safe time-gap to whatever is ahead — another car, a red light, or a queue. Because each car only reacts to the vehicle immediately in front, a sudden slow-down (from a red light, or the "trigger shockwave" button) ripples backward through the queue as a stop-and-go wave, exactly as it does on a real highway.
gap = dist(carAhead) − carLength
accel = a_max · (1 − (v/v_desired)^4 − (safeGap/gap)^2)
v += accel · dt (v clamped to [0, v_desired], hard stop at red)
- Vehicle density — how many cars are spawned on the network; higher density means shorter gaps and a much higher chance that one car's braking cascades into a jam.
- Sim speed — scales simulated time, so slow shockwaves are easier to watch or fast-forward.
- Traffic-light timing — click any light to select it (it highlights), then drag its green/red sliders. Longer red phases build longer queues; well-matched green windows on cross streets keep flow moving.
- Trigger shockwave — forces a random car to brake hard, seeding a visible braking wave that propagates upstream through following traffic.
Real-world relevance: this is the same feedback loop traffic engineers model when timing signals — a single badly-tuned intersection can back queues up for blocks, while adaptive signal timing (metering the green window to actual queue length) is one of the cheapest ways to raise a corridor's throughput without adding lanes.