Dijkstra vs A* on a city grid
What you are seeing: the same shortest-path problem on a procedural city (streets cost 1, piazzas cost 4, buildings and the river are walls). Left, Dijkstra floods outward in all directions; right, A* uses a goal-direction heuristic and drives a tight beam toward the target. At heuristic weight 1, A* is still optimal and finds the same route as Dijkstra with far fewer cells. Push the weight above 1 and A* turns greedy: it reaches the goal scanning even fewer cells, but the path it returns is no longer the shortest, the classic speed-versus-optimality trade-off, while Dijkstra always proves the true optimum. Each panel fires its own bolt the instant that search reaches the goal, so A* can finish and rest while Dijkstra is still flooding; the solved map then holds for five seconds before a new city.
WHAT TO TRY
- Vary each control and watch the rail readouts respond.
- Compare the diagnostic plot against the live scene.