Lesson 2: Step by Step — Writing Exact Grid Algorithms
Learning objective
Students will write and trace an exact, ordered sequence of instructions (an algorithm) to guide a robot token from a start square to a goal square on a 5×5 grid while avoiding obstacles.
Materials
- One printed 5×5 grid per pair (columns labeled
A–E left to right, rows labeled 1–5 bottom to top, matching Maps, routes, and places)
- One small flat object with a clear "front" per pair (a paper triangle, a toy car, or a coin with a drawn arrow) to serve as the Robot
- 3 small erasers or paper squares marked
X as Rocks (Obstacles) and 1 star token ★ as the Goal
Vocabulary
- Algorithm: A clear, step-by-step list of instructions for solving a problem or finishing a task.
- Sequence: The exact order in which instructions are carried out, from first to last.
- Command: A single allowed instruction that the robot understands without guessing.
Allowed Robot Commands (Write on the board)
The robot only understands these four commands—nothing else:
FORWARD 1 — Move 1 square in the direction the robot's nose is currently pointing.
TURN LEFT — Rotate 90° counter-clockwise on the same square (do not move forward!).
TURN RIGHT — Rotate 90° clockwise on the same square (do not move forward!).
PICK UP — Pick up the star ★ on the current square.
Lesson flow
1. Warm-up: The Literal Teacher Robot (8 min)
- Draw a 3×3 grid on the board with the Robot at the bottom-left (
A1) pointing North (up), a Rock X at A2, and a Star ★ at B2.
- Ask a volunteer to tell you how to get the star. If the student says "Go over to the star" or "Turn right and go up," act as a literal robot:
- On
TURN RIGHT, rotate your arrow to face East (right) while staying on A1!
- Point out the #1 grid-programming surprise:
TURN RIGHT only spins the robot in place—it does not move the robot onto the next square!
- Together, write the exact 5-step algorithm on the board and trace the robot's square and facing direction after every single line:
TURN RIGHT (at A1, now facing East)
FORWARD 1 (moves to B1, still facing East)
TURN LEFT (at B1, now facing North)
FORWARD 1 (moves to B2, facing North)
PICK UP (picks up ★ at B2)
2. Direct instruction: Why Order (Sequence) Matters (10 min)
Compare two 3-step algorithms starting at A1 facing North, with a Rock X at A2:
- Algorithm 1:
TURN RIGHT → FORWARD 1 → TURN LEFT (Robot lands safely on B1 facing North).
- Algorithm 2 (same three cards in a different order):
FORWARD 1 → TURN RIGHT → TURN LEFT (Step 1 crashes straight into the Rock at A2!).
Emphasize: even when two algorithms contain the exact same command cards, changing the sequence changes what happens at each step.
3. Guided practice: Programmer & Robot Grid Challenges (17 min)
Students work in pairs on their 5×5 grid (A1 is bottom-left, E5 is top-right):
- Role 1 — The Programmer: Writes the numbered list of commands on paper without touching the robot token.
- Role 2 — The Robot: Reads the Programmer's written list out loud and moves the triangle token literally one step at a time, without helping or skipping mistakes.
- After Puzzle 1, partners switch roles for Puzzle 2.
Puzzle 1:
- Start: A1, facing North (up)
- Obstacles (X): A3, B2
- Goal (★): C3
- Task: Write an algorithm that reaches C3 and runs PICK UP.
Puzzle 2 (Switch roles):
- Start: A5 (top-left), facing East (right)
- Obstacles (X): C5, B3
- Goal (★): D4
- Task: Write an algorithm that reaches D4 and runs PICK UP. Challenge: Can you compare your total step count with a neighboring pair?
4. Wrap-up & Exit check (10 min)
On a 5×5 grid where A1 is bottom-left and the Robot starts at B1 facing North (up):
Row 3: [A3] [B3] [C3] [D3★]
Row 2: [A2] [B2] [C2] [D2]
Row 1: [A1] [B1▲] [C1] [D1]
Answer these three questions:
- Trace this algorithm from
B1 facing North:
- Step 1:
FORWARD 1
- Step 2:
TURN RIGHT
- Step 3:
FORWARD 1
- Step 4:
FORWARD 1
Which square is the Robot standing on now, and which direction (North, East, South, or West) is it facing?
- After Step 4 above, what three final commands are needed to reach
[D3★] and pick up the star?
- Why doesn't
TURN RIGHT move the robot from B2 to C2?
Worked answers for exit check
- After Step 1 (
FORWARD 1), the robot is on B2 facing North. After Step 2 (TURN RIGHT), it is still on B2 facing East. After Step 3 (FORWARD 1), it is on C2 facing East. After Step 4 (FORWARD 1), it is on D2 facing East.
- The three final commands are: Step 5:
TURN LEFT (now at D2 facing North), Step 6: FORWARD 1 (moves to D3), and Step 7: PICK UP.
- Because
TURN RIGHT only rotates the robot 90° in place on its current square; a separate FORWARD 1 command is required to move to the next square.