3
Back and forth
Computing 2: Unit 8, pp. 106–121
GoalUse back and marker up in an algorithm to draw a letter with arms.
New words
back · moves the robot one step the other way, without turningarm · a short line that sticks out of a longer linecorner · a place where two lines meet
Explanation
Back moves the robot the other way without turning. It is a good way to return to a corner. The letter F has a tall line and two arms. The robot draws the tall line and the top arm. Then it backs along the top arm to the corner. Now it can turn and go down to draw the middle arm. If we do not want a line, we put the marker up first.
| Step | Instruction |
|---|---|
| 1 | Start |
| 2 | Marker down |
| 3 | Forward 4 |
| 4 | Turn right |
| 5 | Forward 2 |
| 6 | Back 2 |
| 7 | Turn right |
| 8 | Forward 2 |
| 9 | Turn left |
| 10 | Forward 1 |
| 11 | Stop |
Worked examples
The letter F. The robot starts at the bottom left, facing up. It draws the tall line, goes along the top arm, backs to the corner, goes down and draws the short middle arm.
| Step | Instruction |
|---|---|
| 1 | Start |
| 2 | Marker down |
| 3 | Forward 3 |
| 4 | Marker up |
| 5 | Back 3 |
| 6 | Stop |
Why does the algorithm for F use back 2? After the top arm the robot faces right. Back 2 takes it to the corner in one step. Turning round would need more steps.
Class activity
Draw an F: make a grid of 3 columns and 5 rows on paper. Use a pencil as the robot. Follow the algorithm for the letter F one step at a time with a partner reading it out. Does your F look right? Then change “forward 1” in step 10 to “forward 2”. What happens to the middle arm? Is it still an F?
Practice
1
A robot starts on C1, facing up. It does forward 3 and then back 1. Which square does it stop on? Rows are numbered from the bottom.
C3. Forward 3 takes it to C4. Back 1 takes it to C3.
2
In the algorithm for F, which step takes the robot back to the corner of the top arm?
Step 6, back 2.
3
Why is back 2 better than turning round twice and going forward 2?
Back 2 is one step. Turning round and going forward would take three steps.
4
Write an algorithm for a robot to draw a line of 3 steps and then return to the start without drawing.
Start, marker down, forward 3, marker up, back 3, stop.