Week 3 · Unit 1: Making programs clear · 3 lessons
1
Turns and order
Computing 3: Unit 1, pp. 8–27
GoalFollow and correct algorithms that use turns, and algorithms where the order of the steps matters.
New words
turn · to face a new direction without moving to a new squaredirection · the way something is facing or movingorder · which thing comes first, second, third and so on
Explanation
Some algorithms tell a robot to turn. A turn changes the way the robot faces, but not the square it stands on. “Move forward” always goes in the direction the robot faces right now. So we must track the facing direction after every turn. A robot that faces up and turns right now faces right. The picture shows Move 2 forward, Turn right, Move 3 forward. Order matters in every algorithm: a bus that must stop at the school before the park cannot go to the park first.
Worked examples
The robot starts at the bottom-right corner facing up. Its algorithm is: Move 1 forward. Turn left. Move 3 forward. Turn left. Move 1 forward. After the first turn it faces left. After the second turn it faces down, so the last move goes down to the bottom row.
If one turn is wrong, the whole route changes. A robot at the left edge that turns left will face away from the grid, and its next move would take it off the board. When a route goes wrong, check each turn first.
Step
Instruction
1
Show green
2
Show amber
3
Show red
Order matters for a traffic light too. It must show green, then amber, then red. If the steps are in another order, drivers will not know what is coming next. A computer inside the traffic light follows the steps exactly as they are written.
Class activity
Robot walk (with a friend): one of you is the robot and stands on a start spot, facing a wall. The other gives commands one at a time: “Forward 2”, “Turn right”, “Forward 1”. Remember that a turn is a quarter turn on the spot. Mark where you finish with a piece of paper. Then write the commands down as an algorithm and check that following the list gives the same result.
Practice
1
The robot starts facing up. Algorithm: Move 2 forward. Turn right. Move 2 forward. Where does it finish: the flag, the tree or the house?
The house. It goes up 2, turns to face right, and moves 2 squares to the right.
2
Write an algorithm for the robot to go from the start to the star. The robot starts facing up.
The robot starts at the bottom-left facing up and must reach the tent. Its algorithm is: Move 3 forward. Turn left. Move 2 forward. Which step is wrong? Write it correctly.
The turn is wrong. Facing left at the left edge would take it off the grid. It should be “Turn right”.
4
A school bus must stop at the school, then the park, then the market. The algorithm is: 1 Stop at the market. 2 Stop at the school. 3 Stop at the park. Is it correct? If not, rewrite it.
No, the order is wrong. The correct algorithm is: Stop at the school. Stop at the park. Stop at the market.