Play n Tools

Free tools & games for everyone

Free · No sign-up · No accounts

Pathfinding lab

Draw walls and mud on a grid and watch A*, Dijkstra, breadth-first, depth-first and greedy search find a way from start to goal.

S start G goal wall mud looked at path

How to use

  1. Drag on the grid to draw walls or mud; drag S or G to move the start or the goal.
  2. Pick a method and press Find path. Light cells show where the method looked; the orange line is the path it found.
  3. Compare methods on the same grid: how many cells each one looks at, and whether its path is the cheapest.
  4. Make a maze builds a random maze; Random walls scatters walls and mud.

Keyboard and touch

TabMove to the grid
← ↑ → ↓Move the cursor on the grid
SpaceDraw or remove a wall (or mud) at the cursor
S / GPut the start / the goal at the cursor
RFind the path

Tips

  • Dijkstra and A* always find the cheapest path; A* usually looks at far fewer cells because it heads towards the goal.
  • Breadth-first search finds the path with the fewest steps but ignores mud, so it may wade straight through.
  • Greedy best-first is fast but can be fooled by a wall in the way; depth-first search wanders and gives long paths.
  • Try a maze: there all methods have to look at most of it.

About the lab

Each step to a neighbouring cell costs 1, or 5 into mud; diagonal steps cost 1.414 times as much and cannot squeeze between two walls. A* uses the Manhattan distance (straight moves) or the octile distance (with diagonals), which never overestimates, so its paths are always the cheapest. The tests compare every method with an independent Python Dijkstra on random grids.

With “reduce motion” set on your device the result is shown at once. Nothing is stored or sent.

See you tomorrow!

A fresh daily puzzle every morning, and new tools added every month.

Browse every product