heuristicFn is a function parameter for A* search. It assigns each search state a heuristic score, which combines with path cost to prioritize frontier nodes. section 2.2
A maze-solving implementation uses heuristicFn to:
- Accept a state and return a Float heuristic score. section 2.2
- Initialize and prioritize nodes in a priority queue using cost plus heuristic. section 2.2
- Guide A* toward the goal while retaining optimal paths when the heuristic is good, consistent, and admissible. section 2.2
Distance heuristics for a maze
euclideanDistance computes straight-line distance to the goal. manhattanDistance adds row and column differences, matching movement without diagonals. Either function can be passed as heuristicFn to astar(). section 2.2
