3
New goal, new start
Computing 1: Topic 1.3, pp. 33–48
GoalChange a program for a new goal or a new start square.
New words
goal · where the robot should endstart · where the robot begins
Explanation
We can change an algorithm. Keep the start and pick a new goal. Or keep the goal and pick a new start. Change only the cards you need. Then trace the new code. Check that the robot ends at the goal.
Worked examples
Same start, new goal. The robot starts at the bottom left facing up. The old code F F R F F F reached the slide. For the flower, use R F F F F.
Same goal, new start. The robot starts at the top right, facing down, and the flower is at the bottom right. Code: F F F.
Change one card. The old code F F R F F F ends at the slide. Take away the last F and the robot stops one square before the slide.
Class activity
Change the route: on a floor grid, ask a partner to walk a route with a card code. Now move the toy goal to a new square. Which cards must you change? Change only those. Walk it again.
Practice
1
The robot starts at the bottom right, facing left. The goal is two squares to the left. Write the code.
F F.
2
Old code: F R F F F. Now the duck is on the square shown. Which cards do you remove?
Two F cards at the end. The code becomes F R F.
3
The robot starts on a new square. Do you need the same code?
No. A new start usually needs a new code.
4
What do you do after you change code?
Trace it again to check the robot reaches the goal.