Where search breaks down

The machine follows a greedy rule: at every step, take whatever looks closest to the goal right now. This is one general search strategy, not a description of every system that searches.

In the first maze, greedy worked. In the second, it walked the machine straight into the trap. The goal was sitting right there, but the safe route began by heading away from it. Greedy never does that. It cannot choose a step that looks worse now, even when that step begins the better path.

Imagine driving to a town across a river. The nearest bridge is closed. The best route begins by driving away from the town so you can reach the next bridge.

One turn at a time, that route looks wrong. As a complete path, it is the one that gets you there.