Search · A* Algorithm
Pathfinding
Find the shortest path from start to goal on a grid full of walls. A* is the classic: it spreads outward like a flood, but cleverly prefers cells that look closer to the goal — so it finds the optimum without checking everything.
How it works
- Each cell gets a score: the cost so far (g) plus an estimate of the distance left (h, the heuristic).
- Always expand the most promising cell next. The bright frontier creeps toward the goal; visited cells fade behind it.
- When the goal is reached, follow the parent pointers back — that's the shortest path, in gold. Draw walls and it re-plans instantly.
Pathfinding and route optimization are cousins: both search enormous spaces of “ways to get there” and rely on smart shortcuts instead of trying everything.