Pico / Demos

Königsberg on the Pregel

Traffic control

Königsberg has seven bridges. The Department of Traffic Cones has put you in charge of all seven. Click a road to close or reopen it and watch the drivers find a way around. How drivers choose a route

Frames per second—
Simulation time / tick—
Mean time to update roads, routes and drivers over the last second. FPS includes drawing.

The seven bridges

CarFaster SlowerClosed road
About the map and routing

City clock runs at 30 driving ticks per second. City time lapse advances a fixed number of driving ticks before drawing each frame. Both use the construction rates you choose. FPS counts frames that show a new simulation state. The optional stress replay rotates closures and reopenings across the busiest crossings or streets. Each report advances traffic by one tick. Replay speed sets how many reports the city processes before drawing every car. Reset City repeats the replay from the selected seed.

This street map follows the seven historical bridge connections. Five bridges meet on Kneiphof, the cathedral island. Lomse and the two riverbanks each have three. The streets and traffic are simulated. Historical map and graph (MIT BLOSSOMS)

Each intersection admits a limited number of cars per second. Cars wait in arrival order for space on their chosen road. Busy roads take longer to travel. Every second the route planner checks traffic levels. Opening or closing a road updates routes immediately. Drivers whose destinations become unreachable wait at the next intersection until a route opens.

Drivers heading to the same destination share a reverse Dijkstra search. Drivers at the same intersection going to that destination subscribe to the same next turn. A road closure or reopening rebuilds only destination searches whose active turns could depend on that road. Drivers receive updates when their next road changes. A fixed seed repeats the same trips and road events when the same actions occur at the same tick.

Simulation time per tick includes road events, route searches, signal updates, driver movement and queues. Each second the timer divides the time spent advancing traffic by the number of completed ticks. A manual step shows the time for that tick. Drawing and waiting for the next frame are outside this timer.