2
Plan, code, trace
Computing 1: Topics 1.1–1.4, pp. 9–59
GoalPlan a route in words, write the code, and trace it.
New words
code · commands a robot understandstrace · follow the code one card at a time
Explanation
The floor robot has command cards: forward, back, turn left, turn right, clear, pause and GO. A turn is a quarter turn on the spot. A program starts with clear and ends with GO. Plan in words, change it to code, then trace the code on the grid.
Worked examples
Plan: at the zoo, the robot starts top right facing left. It must reach the penguin. Say: forward two, turn left, forward two. Code: X F F L F F GO.
Trace: start bottom left facing up. Code: R F F L F. It goes right two, turns left, and goes up one. It ends at C2.
Bug: the robot should reach the giraffe. Code: X R F F GO. It stops one square early. The fix is one more F.
Class activity
Zoo route: draw a grid of squares on paper. Put a start square and a goal such as an elephant. Write a code with clear first and GO last. Swap with a partner. Trace each other’s code with a finger. Do you both end on the goal?
Practice
1
The robot starts at the bottom right facing up. It must reach the lion. Write the code.
X F L F F GO. (Up one, turn left, forward two.)
2
Trace: start at D1 facing up on a 4 by 4 grid. Code: F L F F. Where does the robot end?
B2. (Up one, turn left, forward two.)
3
Which button do you press first? Which last?
Clear first. GO last.
4
Say this code in words: B R F F.
Back, turn right, forward, forward.