The maze S is the start and the flag is the goal. Black blocks are walls, brown cells are mud: entering mud costs 3, entering a plain cell costs 1. A* will look both back and ahead.
f = g + h: 7 cells opened The numbers are f: the cost to get here g plus the estimate left to the goal h. A* always opens the cell with the smallest f; cheap paths that lead away from the goal fall behind. 4 cells are on the frontier.
f = g + h: 13 cells opened 17 17 19 17 17 19 17 17 19 17 17 17 17 19 17 17 17 S The numbers are f: the cost to get here g plus the estimate left to the goal h. A* always opens the cell with the smallest f; cheap paths that lead away from the goal fall behind. 5 cells are on the frontier.
f = g + h: 19 cells opened 17 17 19 21 17 17 19 17 17 19 21 17 17 17 17 19 21 17 17 19 17 17 19 S The numbers are f: the cost to get here g plus the estimate left to the goal h. A* always opens the cell with the smallest f; cheap paths that lead away from the goal fall behind. 5 cells are on the frontier.
f = g + h: 25 cells opened 17 17 19 21 23 17 17 19 17 17 19 21 23 17 17 17 17 19 21 23 17 17 19 17 17 19 21 23 S The numbers are f: the cost to get here g plus the estimate left to the goal h. A* always opens the cell with the smallest f; cheap paths that lead away from the goal fall behind. 4 cells are on the frontier.
f = g + h: 31 cells opened 17 17 19 21 23 25 17 17 19 17 17 19 21 23 25 17 25 17 17 17 19 21 23 23 17 17 19 25 23 17 17 19 21 23 23 23 S The numbers are f: the cost to get here g plus the estimate left to the goal h. A* always opens the cell with the smallest f; cheap paths that lead away from the goal fall behind. 6 cells are on the frontier.
f = g + h: 37 cells opened 17 17 19 21 23 25 17 17 19 17 17 19 21 23 25 17 25 17 17 17 19 21 23 23 17 17 19 25 23 25 17 17 19 21 23 23 23 23 23 23 S The numbers are f: the cost to get here g plus the estimate left to the goal h. A* always opens the cell with the smallest f; cheap paths that lead away from the goal fall behind. 5 cells are on the frontier.
The cheapest path with less work 17 17 19 21 23 25 17 17 19 17 17 19 21 23 25 17 25 17 17 17 19 21 23 23 17 17 19 25 23 25 17 17 19 21 23 23 23 23 23 23 S The path costs 23, the same as uniform cost. A* opened 37 cells; the estimate steered the search toward the goal.
Why it matters 17 17 19 21 23 25 17 17 19 17 17 19 21 23 25 17 25 17 17 17 19 21 23 23 17 17 19 25 23 25 17 17 19 21 23 23 23 23 23 23 S Characters finding their way in games, route planning in map apps and robots moving around use A* or its variants.