| Improving Heuristics for A* Pathfinding(redblobgames.com) | |
| 334 points by bobbiechen 25 days ago | 37 comments | |
tl;dr: A* pathfinding can be significantly sped up by improving its heuristic function using precomputed "landmarks": pick fixed nodes, run Dijkstra from each to store distances to every map node, then use the triangle inequality (cost(B,X) ≥ |cost(B,L) - cost(X,L)|) to derive a tighter lower bound than Euclidean/Manhattan distance. This "differential heuristic" requires no changes to A* itself—just a better heuristic function and a 2D cost table—and works especially well on mazes and maps where straight-line distance misleads the search. | |
HN Discussion:
| |