Combining past cost with an estimate
For a candidate state, g is the best currently known start-to-state path cost and h estimates the remaining cost. A* prioritizes f=g+h, combining considerations that greedy h-only search and g-only uniform-cost search treat separately.
The estimate must fit the cost model. Manhattan distance lower-bounds remaining steps on a unit-cost orthogonal grid after ignoring walls. Different moves or costs require rechecking the heuristic rather than reusing that formula automatically.
References: [1]
Admissibility and consistency have different roles
An admissible heuristic never overestimates true remaining minimum cost and is zero at a goal. On a finite search tree with nonnegative edge costs, correct A* with this bound preserves optimality. Setting h=0 recovers uniform-cost priorities.
Consistency additionally requires h(u)≤c+h(v) across an edge of cost c. With appropriate queue and closing rules it supports avoiding repeated expansions; an admissible but inconsistent heuristic may require reopening states reached more cheaply later.
Repeated states need path-cost checks
Several paths can reach one state. Permanently discarding it after first discovery can miss a later lower-g route. Correct implementations compare costs and update or reopen as required; generating a goal is not automatically the correct stopping event.
A more informative lower bound can reduce exploration but also costs computation, while the frontier consumes memory. A* does not make every search fast or repair an insufficient state representation that merges situations with different future actions or costs.