How does a ghost chase you through a maze? Not by guessing — by A*, which explores toward the goal using a hint (the straight-line distance) so it barely wanders. Slide the greed (or tap): trust the hint more and it finds a path faster, but risks a longer one.
A* search on a grid. It expands the frontier cell with the lowest f = g + w·h, where g is the steps taken and h is the Manhattan distance to the goal (an admissible hint). At w=1 A* is guaranteed to find a SHORTEST path while exploring far fewer cells than a blind flood; raise the weight and it turns greedy — reaching the goal sooner but no longer guaranteed optimal. The path and every explored cell are computed live. A fail-loud self-check throws unless w=1 returns a path whose length equals the true shortest and a heavier weight explores fewer cells.
A small fixed maze and 4-connected moves (no diagonals); real pathfinders add weights, jump-point search, hierarchical graphs. The A* expansion, the g+w·h ordering and the path are computed exactly.