3
Follow a path
Computing 2: Unit 8, pp. 106–121
GoalWrite the steps that take a robot along a path to a goal.
New words
path · the line a robot follows from start to endstep · one instruction in an algorithmGO · the card that tells the robot to run its commands
Explanation
A robot can follow a path on a grid. We look at where it starts and which way it faces. We write one step for each move or turn. In this path the robot goes forward 3, turns right and goes forward 3. That is 7 steps, because each forward is one step. We can put the steps on command cards and press GO.
Worked examples
| Step | Instruction |
|---|---|
| 1 | Forward |
| 2 | Forward |
| 3 | Forward |
| 4 | Turn right |
| 5 | Forward |
| 6 | Forward |
| 7 | Forward |
The same algorithm as command cards. Press GO and the robot runs them from the first card to the last.
A different path. The robot starts on the right side of the grid, facing left. It goes forward 2, turns right and goes forward 3, so it reaches the star.
Class activity
Command cards: make cards for forward, back, turn left, turn right and GO. Make a grid on the floor and put a toy at the end. A partner is the robot. Lay the cards in a row for a path from the start to the toy. Then press GO: the robot does each card in order. Did it reach the toy? If not, find the card that is wrong and change it.
Practice
1
Write the algorithm for the path as numbered steps. The robot starts at the bottom right, facing up.
1 forward, 2 turn left, 3 forward, 4 forward, 5 forward.
2
A robot starts on D4 facing down. It does forward, forward, forward, turn right, forward. Which square does it stop on?
C1. Three forwards take it to D1. Facing down, its right is our left, so it turns and moves to C1.
3
What does the GO card do?
It tells the robot to run all the commands in order.
4
The robot does forward, forward, forward, turn right, forward, forward, forward. How many times does it move forward?
6 times.