Skip to main content

Maze Runner

Race your own path through a maze, then watch BFS find the provably shortest route, and DFS show why 'a path' isn't 'the shortest path'.

BFS shortest pathDFS traversalpath reconstructiongrid graphsRead the lesson
How to play
  1. Move from the green start to the violet goal using arrow keys or the on-screen pad.
  2. After you finish, run BFS: it explores in rings and reconstructs the shortest path.
  3. Switch to DFS to watch a deep-dive exploration and compare its path length.
  4. Three handcrafted mazes, sized up as you go.
maze1 / 3moves0wall bumps0shortest20

Move from A (green) to B (violet) with the arrow keys or the pad. Every step counts, after you arrive, BFS will judge your route.

Move (arrow keys / WASD also work)

What's the difference?

BFS expands in rings around A using a queue, the first time it reaches B, the path is guaranteed shortest (unweighted maze). DFS dives down one corridor using a stack, it finds a path, whatever length it happens to be.

Estimated play time: 5–8 min. Scores feed your local progress, stored only in this browser.