How many cars can the grid take before it locks up? Intersections show green while eastbound (cyan) cars have the light and red while southbound (amber) cars do. At the default green-ticks of 12, all of them switch together every 12 ticks.
Try this Set number-of-cars to 400 and slowdown-chance to 50, then press Reset (number-of-cars is read only at setup). Within about 1,500 ticks the queues back up through the intersections in a closed loop and moving-cars drops to 0 for good. The Gridlock preset (320 cars, slowdown 20) never gets there.
About this model Where it ends up The run never stops by itself. At the defaults and presets, moving-cars and average-wait keep oscillating with the lights. Gridlock, when it comes, is permanent. moving-cars stays at 0 and average-wait climbs by 1 every tick.
A port of Uri Wilensky's NetLogo Traffic Grid. Cars share a lattice of one-way streets whose intersections all run on one fixed-time signal, so queues build at every red light and drain at the next green. Only at extreme loads do queues back through the intersections far enough to lock the grid.
Setup lays a road every block-size patches in each direction on a 49 × 49 torus. Even-numbered cars drive east and odd ones south, starting on random road cells. Each tick, in random order, a car moves 1 cell unless the cell ahead held a car at the start of the tick (so a queue starts moving one car per tick), or the cell ahead is an intersection showing red, or it hesitates at slowdown-chance percent. A car already inside an intersection ignores the light and never hesitates. The lights switch every green-ticks ticks. number-of-cars and block-size apply at Reset; green-ticks and slowdown-chance are read every tick.
At the defaults and in every preset the grid keeps flowing. Permanent gridlock, with queues backed up through intersections in a closed loop, needs about 400 cars and a slowdown-chance near 50.