Distinguish a path cost from a heuristic

Keep the names of states and actions distinct. · 201 words

An AI museum guide searches from a library to a museum. The path cost, written g(n), is the exact sum of the edge costs along the route taken to reach node n, meaning a search state. The library-to-park edge costs 4 minutes, and the park-to-museum edge costs 5 minutes, so the path through the park has g = 4 + 5 = 9 minutes. The direct library-to-museum edge costs 7 minutes, so its path cost is 7. A uniform-cost search compares these exact totals when deciding which reached node to expand next.

Consider a different AI: a hiking app choosing a trail. After the hiker has walked 6 kilometers, the path cost is g = 6 because the traveled distance is known exactly. The heuristic, written h(n), estimates the cost still required to reach the goal. Here h = 4 kilometers, although the actual remaining trail is 5 kilometers. This estimate respects the admissibility rule because it does not overestimate the remaining cost. A common A* search score is f(n) = g(n) + h(n): cost so far plus estimated cost left. Here f = 6 + 4 = 10. The path cost records a fact. The heuristic supports a guided guess.

Check your recall

At the hiking point, g = 6 km, h = 4 km, and f = 10 km. Which value is an estimate, and why is the heuristic admissible?

Check your answer

The heuristic h = 4 km is the estimate of the remaining cost. It is admissible here because 4 km does not exceed the true remaining cost of 5 km. The value g = 6 km is an exact path cost, while f combines known and estimated costs.

Sources and credits

Original KeyTouch lesson. Background reading · UC Berkeley · Introduction to Artificial Intelligence.