Lesson 03 of 05 · about 4 min

Walk the grid

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5

A* expands the cell with the smallest cost-so-far plus a heuristic. On a grid of orthogonal steps, Manhattan distance to the goal never overestimates, so the first time the goal is expanded the path is shortest.

Moves are up, down, left, and right. S is the top-left cell, G is the bottom-right, and the center cell is blocked. Enter the number of steps in a shortest path.

On the Knowledge page

Resources