Tykun
Games

Small science games by Tykun

Sheet 03 · Physics note · Traffic Simulator

The physics of Traffic Simulator

Try the early version Try it on a computer

Status

A game in the works

An early version of Traffic Simulator is playable. It may be unstable. This note is about the physics it is being built on.

Try the early version Try it on a computer

What the game will let you do

You can play an early version of Traffic Simulator, and it may be unstable. What follows is the physics it runs on, and where something is not proven I say so.

You draw a road network, give the roads lanes and speed limits, set what happens at each junction (a signal, a STOP sign, a yield, a roundabout) and watch cars, buses and trucks drive it. It comes with ten ready-made maps: seven that show one piece of the physics working, such as cars overtaking slow trucks on a highway, and three that jam on purpose, for one cause you can fix in the editor. The cars are simulated on your own computer, with no server doing the driving.

Following the car ahead

Each driver reacts to one thing, the car in front. The game uses the Intelligent Driver Model of Treiber, Hennecke and Helbing (Treiber). It gives the acceleration from four numbers: your speed v, the bumper-to-bumper gap s, how fast you are closing on the leader Δv, and the speed v0 you would like to drive at:

v˙=a[1−(vv0)δ−(s∗s)2],s∗=s0+vT+vΔv2ab

The first term is the push to reach v0. The second is the brake, and it grows as the gap falls below the gap s∗ the driver wants. For cars the game takes the paper’s set (reference 1): a=0.73 m/s² of acceleration, b=1.67 m/s² of comfortable braking, s0=2 m of gap at a standstill, δ=4, and a car 5 m long. The headway T=1.5 s is the car value on Treiber’s reference page for the model (reference 3), whose own a and b differ; the paper gives T=1.6 s. The desired speed v0 is the road’s speed limit, and the examples below use 30 m/s (108 km/h). The bus and truck rows are my own picks inside the realistic bands that Treiber’s reference site gives, and the game labels them that way.

A worked case. On a road limited to 30 m/s, a car at 25 m/s sees a stopped car 200 m ahead. The wanted gap is 322 m, so the brake term wins and the model asks for about −1.5 m/s², just under the comfortable 1.67. The figure depends on that limit: with v0 at 25 m/s the same car would be asked for about −1.9. Braking starts early and eases off as the gap closes.

Two choices of mine sit on top of the model. Every vehicle moves at once, from the positions it had at the start of the step, so a follower reacts one step late. And the braking is capped at −9 m/s²: the classic model asks for far more when a car is suddenly going faster than it wants to, for instance when a bend caps the speed at 1.5R for a bend of radius R in metres.

Set the acceleration to zero and the model has a steady state for each speed, where every car keeps the same gap:

se(v)=s0+vT1−(v/v0)4

At a standstill that is 2 m plus the 5 m car, 7 m a car, or about 143 cars a kilometre. With v0 at 30 m/s, cars at 17 m/s keep about 29 m and the lane carries about 1,800 cars an hour, which is the most this steady state allows. That figure is my own arithmetic, not yet proven in the running game. In the running game I measured 1,524 cars an hour, below that, and I have yet to tune the car settings to close the gap.

Changing lanes

A driver changes lane by the MOBIL rule of Kesting, Treiber and Helbing (Kesting), which is built on the same car-following model. The driver compares what each car would feel, in acceleration, with and without the move: the driver e, the follower in the old lane o, and the follower in the new lane n. A tilde marks the value after the change.

a~e−ae+p[(a~o−ao)+(a~n−an)]+Δb>athr

Before that, a safety test. If the new follower n would have to brake harder than bsafe=4 m/s², the change is refused, whatever the gain. The test looks at that follower only. The driver’s own gap to the new leader is left to the sum above.

The politeness p says how much the others’ losses count: the game uses 0.35. The threshold athr of 0.2 m/s² stops changes for a marginal gain, and the keep-right bias Δb of 0.2 m/s² nudges drivers back to the right-hand lane. Those numbers come from Treiber’s reference page for MOBIL, which gives politeness from 0 to 0.5.

Two things differ from the paper. The game looks again once a second, and a car that has just changed waits 5 s before it may do so again. And the move is not instant: the car slides across over 12 to 100 m of road, along a smooth curve, and only one change runs at a time. A driver who must reach a turn lane looks 100 to 200 m ahead and accepts a threshold of −1 m/s², which is putting up with a worse ride to get into the right lane.

How a jam appears from nothing

This is the part I most want to show you, and the part I can vouch for least. The cars follow the model above, with holds at junctions, and the game has no setting for how fast a queue drains. Queues form and empty on their own from the cars’ braking and acceleration.

The published side is this. Treiber and his colleagues set this model against data from German freeways, where the jams were localized or extended, steady or oscillating, and report that all the observations, including states living side by side, are reproduced qualitatively. Treiber’s reference page adds that very low acceleration values favour the formation of stop-and-go traffic. So a wave is expected from the model.

What I have not done is watch one in the game, and a stop-and-go wave is something you have to see moving. Until I have run a long road and looked at it in motion, I count it as not proven here.

Junctions

A junction never drives a car. It decides hold or go, and a car told to hold gets a stopped car placed at its stop line, which the model then treats as any leader ahead. The queue and its release come from the model, with nothing added.

A signal runs a fixed cycle: 3.5 s of amber, 1.5 s with every direction red, and at least 5 s of green. A STOP sign makes a car stand for 1 s, and cars then go in the order they arrived. A yield or a roundabout works by gaps. The car looks at the time before the nearest conflicting car arrives, in seconds and not in metres, and goes if the time is at least the critical gap, or for the next car in a stream the shorter follow-up time:

MovementCritical gap (s)Follow-up time (s)
Right turn4.02.2
Straight through5.53.0
Left turn7.03.3
Roundabout4.52.6

These are the game’s defaults, shaped like the usual table of such gaps for two-way stop junctions. They are not a standard’s numbers: I could not read the figures of the US Highway Capacity Manual, and I did not invent any in their place. A car waiting on a minor road is also served after 60 s, so that busy traffic cannot hold it forever. That is a rule of mine, not a finding.

Turning slows traffic too. A car takes a junction bend at the speed a sideways acceleration of 1.75 m/s² allows, and a bend inside a road at 1.5 m/s².

References

  1. M. Treiber, A. Hennecke and D. Helbing, “Congested traffic states in empirical observations and microscopic simulations”, Physical Review E 62 (2000) 1805. doi:10.1103/PhysRevE.62.1805 (accessed November 2, 2026)
  2. A. Kesting, M. Treiber and D. Helbing, “General lane-changing model MOBIL for car-following models”, Transportation Research Record 1999 (2007) 86. https://mtreiber.de/publications/MOBIL_TRB.pdf (accessed November 2, 2026)
  3. M. Treiber, “Intelligent Driver Model (IDM)”, traffic-simulation.de. https://traffic-simulation.de/info/info_IDM.html (accessed November 2, 2026)
  4. M. Treiber, “Lane-changing model MOBIL”, traffic-simulation.de. https://traffic-simulation.de/info/info_MOBIL.html (accessed November 2, 2026)

Revised November 4, 2026.