G
Merton Games

Pathfinding Lab

Build a maze, solve it manually, or watch algorithms find the optimal path.

Start
Goal
Wall
Path
Visited

Sandbox Tools

Algorithm Settings

Why this teaches algorithms

A maze is really a graph in disguise. Each square is a node, each valid move is an edge, and the goal is to find the best route through the search space.

Pathfinding algorithms do not guess randomly. Breadth-first search expands evenly, Dijkstra's algorithm tracks the cheapest known route, A* uses a heuristic to aim toward the goal, and greedy search prioritizes what looks closest right now. By watching the search unfold, students can see how different algorithms explore, prune, and optimize.

BFS

Explores evenly in all directions. It guarantees the shortest path on unweighted grids but can be slow as it visits many unnecessary nodes.

Dijkstra

The father of pathfinding. It finds the shortest path by always expanding the node with the lowest cumulative cost from the start.

A* Search

The industry standard. It uses a heuristic (estimated distance to goal) to "guide" Dijkstra, making it much more efficient while still finding the best path.

Greedy Best-First

Focuses purely on the goal. It's very fast but can easily get stuck in dead ends or find sub-optimal routes because it ignores path history.