Informed Search
Navigating a robot through a grid maze with A-star and greedy best-first search, using Manhattan and Euclidean distance as admissible heuristics.
╌╌╌╌
Informed search uses a heuristic estimate of the cost remaining to the goal to decide which state to expand next, reaching the goal after touching far fewer states than blind search. This project drives a robot across a grid maze of obstacles to a target cell, comparing A* search against greedy best-first search.
Each frontier state is scored by
where is the cost already paid to reach and estimates the cost from to the goal. A-star always expands the state of lowest . Greedy search drops the term and expands by alone — quicker to commit, but with no account of the path so far it can settle for an expensive route.
On a grid the estimate is a distance to the goal cell. For four-connected movement, Manhattan distance
counts axis-aligned steps; when diagonal moves are allowed, Euclidean distance fits the true geometry. Both are admissible — never overestimating the real remaining cost — which is exactly the condition under which A-star returns an optimal path.
Two properties of a heuristic control what A* guarantees:
- Admissible. at every node, where is the true remaining cost. The estimate never overshoots.
- Consistent. across every edge — a triangle inequality on the estimate. Consistency implies admissibility, and it makes nondecreasing along any path, so A* settles each node's optimal the first time it expands it and never reopens one.
Admissibility is enough for optimality, and the argument is short. Let be the optimal cost and suppose a suboptimal goal with sits on the frontier. Some node on an optimal path is on the frontier too, and there
A* expands the smaller first, so it reaches — and eventually the true goal — before it would ever remove . Overestimating breaks this: an larger than can inflate a good node's past a bad goal's and let the bad goal out first.
Among admissible heuristics, larger is better. If everywhere, dominates , and A* with expands no more nodes than with : every node A* can safely skip under it also skips under . The pointwise maximum of two admissible heuristics is itself admissible and dominates both, which is why heuristics are often combined by taking their max.
- 1input: a start cell, a goal cell, a heuristic
- 2frontier priority queue holding with key
- 3
- 4while frontier is not empty do
- 5remove the state of least key from frontier
- 6if then return the path traced back to
- 7for each neighbor of do
- 8
- 9if is unseen or then
- 10; set 's parent to
- 11insert into frontier with key
- 12return failure
Greedy search often expands fewer states, since it heads straight at the goal, but it gives up optimality: a heuristic that points toward a dead end walks the robot into it. A-star pays for more expansions with a guarantee — under an admissible heuristic the first goal it removes from the frontier sits on a shortest path. Setting collapses A-star to uniform-cost search, and a sharper narrows the search toward the goal without breaking that guarantee.
References
- Project repository
- Reference notes: Informed Search and A*
- Reference notes: Heuristic Functions and Memory-Bounded Search
╌╌ END ╌╌