How drivers choose a route
Drivers heading to the same destination share one route search. Drivers at the same intersection heading to that destination also share their next turn.
Finding the quickest path
Each open road has a positive travel time. Congestion can make a short road slower than a long one. A closed road has infinite cost. If a driver can leave A only through B or C, the quickest time to D is
best(A, D) = min(
cost(A, B) + best(B, D),
cost(A, C) + best(C, D)
)
Try 5 minutes, then 2. Both changes trigger a search. Only one changes the first turn.
The game runs Dijkstra’s algorithm backward from D. The trip from D to itself costs zero. From each intersection, the search follows roads that drivers can take to enter that intersection. A one-way road from B to D lets the search work backward from D to B.
With C–D at 6 minutes, the search starts with B at 3 minutes and C at 6. It examines B first. Going from A through B costs 6 minutes, so A joins the queue at 6. No remaining intersection has a shorter time. The search can answer the driver at A with A–B. If C–D falls to 2 minutes, going through C takes only 4 minutes, so the answer changes to A–C.
One search serves every origin whose destination is D. It keeps the shortest times and first turns it has already established, along with the intersections still waiting in its priority queue. If a driver at another origin needs a turn toward D, the search either returns an established turn or continues until it can answer.
Which changes reach a driver?
Both drivers below are at A and need to reach D. They subscribe to the same A–D turn. A third driver starting at B would use the same search for D and subscribe to a different turn, B–D.
- Active origin–destination pairs
- 1
- Searches on last change
- 0
- Turn deliveries on last action
- 0
The search records when it first inspected each road and when it established each requested turn. If a changed road was first inspected after all the turns still in use were established, those answers remain valid. Otherwise the game rebuilds that destination’s search once for the changed roads and answers all its active origins. A closed road counts as inspected: reopening C–D could change the fastest trip from A.
For each origin–destination pair in use, Pico stores the first road in a source. One derived node reads that source. Each driver retains that same node with a callback that writes the driver’s next turn. If C–D drops from 6 minutes to 5, the search runs again, A–B still wins, and neither callback runs. At 2 minutes the best turn changes to A–C and both callbacks run.
Uncheck one driver. The other keeps the A–D turn and the search for D alive. Unchecking both releases both subscriptions, removes the turn and discards the search because no other driver needs D. With both drivers unchecked, change C–D. There is no search or delivery. Checking a driver acquires a new turn and delivers its current value immediately.
In the game, a driver reaching a new intersection releases the previous subscription and subscribes to the turn for the new origin and destination. A driver partway down a road only changes position. If no open path reaches the destination, the driver waits at the intersection until a road reopens.