NEW Explore the Scratch Block Dictionary, tutorials, textbook, and classroom guides

Start learning →

Intro to Grid Pathfinding (BFS)

📌 What you will learn

Help enemies navigate around maze walls toward the player using breadth-first search on a grid.

Core approach

Number each reachable tile by its distance from the goal (0, 1, 2, 3...) using a queue list; enemies simply step to the neighbor with the lowest number.

  • Keep the grid compact (e.g., 16×12) for fast frame updates.
  • Recompute the distance grid only when the player changes tiles.
  • Combine with smooth gliding between tile centers.

Pro tip & next steps

BFS guarantees the shortest path around obstacles.

All Techniques Browse more English guides in this section. Learn more → Scratch Block Dictionary Look up any Scratch 3.0 block with examples. Learn more →

FAQ

What is the best first step for "Intro to Grid Pathfinding (BFS)"?

Keep the grid compact (e.g., 16×12) for fast frame updates. BFS guarantees the shortest path around obstacles.

This guide is provided for educational purposes. Scratch screens and terms may change over time, so please check the official Scratch website as well.