Rohim’s shortcut on the plot map of the big board: a real A* with a heap queue, g + h on every square, water you draw; Manhattan, the straight line, h = 0…
Why it matters
Pathfinding in games, robots, maps and route planning uses A*: the same result as Dijkstra for one goal, with far fewer checks. The usual mistakes: a heuristic too big (the path is no longer the shortest) and a heuristic that does not fit the way you step (Manhattan with diagonal steps).
The key idea
h must never exceed the real distance
Common mistakes
A* gives a path that is not the shortest Its heuristic exceeds the real distance. Make sure h is *admissible*: never more than the real distance left. Multiplying h (weighted A*) knowingly trades the shortest path for speed.
A* checks every way like Dijkstra Its heuristic is zero or too small. With h = 0, f = g and A* is Dijkstra. Use an h as close to the real distance as you can without exceeding it: Manhattan for four-way steps.
Diagonal steps with Manhattan One diagonal step cuts 2 off Manhattan but costs √2: Manhattan becomes too big. Use the octile distance (max + (√2 − 1) × min) or the straight line, and give diagonal steps a cost of √2.
Try it in this playground
Reach the market Run to the end and watch the path read back through asal.
h = 0 is Dijkstra Pick h = 0, run to the end, and compare the squares checked.
Draw water Press a square on the map to make it water or land.
A longer path Run to the end with an h too big, or Manhattan with diagonal steps.