Watch Encyclopedia

Finding the Shortest Route

How does a map app find your route? Build a maze and watch two classic methods search it.

What you are seeing

Blue squares are places the search has looked at. The gold line is the shortest route it found.

The first method is called breadth-first search. The second is called A-star, and it uses a guess of the distance left to steer the search toward the goal.

Try this

  • Draw a wall with one small gap.
  • Box B in completely and see what happens.
  • Switch methods and compare how many squares get checked.
  • Press Random walls a few times.

Numbers

A-star published
1968
Moves allowed here
Up, down, left, right

Keep watching

More to explore