Lab
Logic you can see.
Pick a goal anywhere on the grid and watch the algorithm find the shortest way around my name. Hover to preview, click to replay the search.
- Walls (my name)
- Visited
- Shortest path
- Start
- Goal
BFS: breadth-first search
Explores outwards in rings, every cell one step away, then two, then three. The first time it reaches the goal is guaranteed to be a shortest path, but it searches in every direction to get there.
A* search
Same guarantee, smarter order. It ranks cells by steps taken so far plus an estimate of the distance left, and always expands the most promising one first. Compare the visited counts: on an open grid it often checks a fraction of what BFS does.