2
Find the bug
Computing 1: Topic 1.4, pp. 49–59
GoalTrace code to find which card is the bug.
New words
too many · more than we needwrong turn · a turn card that points the wrong way
Explanation
To find a bug, trace the code on the grid. Compare where the robot ends with where it should end. Look at the cards one by one. A bug may be one card too many. It may be a turn the wrong way. It may be a card missing.
Worked examples
The robot should stop at the flower. Code: F F R F F F. It goes up two, turns right, and goes forward three. It goes past the flower. One F is too many.
The robot should go to the apple at the left. Code: F F R F F. It turned right, but the apple is on the left. The bug is the R. It should be L.
Another bug: Mia pressed clear, forward, forward, turn right, forward, but never pressed GO. The robot did not move at all. The bug is the missing GO.
Class activity
Bug detectives: write a code of five cards on paper that gets a toy to a goal on the floor grid. Swap with a partner. Each of you changes one card in the other’s code so it has a bug. Trace the code to find your bug and say which kind it is.
Practice
1
The robot should reach the duck. Code: R F F F F. Which card is the bug?
One F too many. The robot goes past the duck.
2
The robot should reach the tree. Code: F F. It stops too soon. What is the bug?
A card is missing. It needs one more F.
3
The robot should go forward, turn right, forward. Code: X F L F GO. Which card is the bug?
The L. It should be R.
4
Name two kinds of bug in a robot code.
For example: a card too many, a card missing, a wrong turn, a missing GO.