Nagel–Schreckenberg traffic
Explore traffic on a ring road: reproducible starts, conserved vehicles and stop-and-go waves.
About this tool
Generate creates step 0; Step applies one complete update. Run/Pause/Resume keep the current road. Even spacing and Traffic jam place stopped vehicles regularly or in one cluster; Random chooses reproducible occupied sites. Density sets exactly round(length × density / 100) vehicles. Settings changes discard the old trajectory.
For every car in parallel: increase speed by one up to the limit, reduce it to the number of empty sites ahead, then reduce positive speed by one with the chosen braking probability. Finally move all cars simultaneously. Empty sites and stopped cars are distinct; vehicles cannot disappear or overlap on this closed ring. Custom cells use spaces: 0 . . 0 . ., limit 1, braking 0 gives . 1 . . 1 . after one step. Positions start at 0; the last-transition table shows each rule stage.
Density is vehicles/road cells; mean speed is cells/model step; flow is the sum of the latest car speeds divided by road length. This is a spatial mean, not a single-site detector measurement. Red means stopped, yellow slower movement and green faster movement. The top strip is the current road; below it the last 80 states show time downward and motion rightward. Animation timing only controls playback, not model units. Leaving the tool pauses it; returning/reloading retains input drafts, including invalid values but starts a new trajectory on demand.
3–320 cells, speeds 0–8, density/braking 0–100%, integer seed 0…4294967295, interval 50–2000 ms. Each update costs O(length + vehicles). A one-lane periodic teaching model without overtaking, entrances or calibrated physical units; it is not a traffic forecast. Source: Nagel & Schreckenberg (1992).
Input drafts are stored locally; older JSON and semicolon settings remain readable. Very large drafts keep the previous saved copy and show a warning. Reload and navigation preserve the inputs, while Generate explicitly starts a new trajectory. The flow chart shows even a single initial sample; its scale uses the model units in the heading.