Short programs and resets
Answers are for parents and teachers.
1
Write the algorithm for a sprite: move 10 steps, move 10 steps, move 10 steps, move 10 steps, say Hi. Then write a shorter version. How many blocks did you save?
Shorter: move (40) steps, say Hi. The first version has 5 blocks plus the hat, the second has 2 plus the hat. It saves 3 blocks.
2
On a paper line numbered −4 to 4, put a coin on −2. The program is “change x by 3”. Move the coin for 3 clicks with no reset. Then try again with a “go to x: −2” at the start. Where does the coin finish each time?
No reset: 1, 4, then 7 (off the line). With the reset: −2 + 3 = 1 every time.
3
A sprite starts at size 100 and the program has “change size by (25)” once. Fill in the size after clicks 1, 2 and 3 with no reset, and with “set size to 100” at the start.
| Click | No reset | With reset |
|---|---|---|
| 1st | ? | ? |
| 2nd | ? | ? |
| 3rd | ? | ? |
No reset: 125, 150, 175. With reset: 125, 125, 125.
4
Tell a grown-up why a game program needs a reset at the start.
Without a reset the characters start where they ended last time, so the game would not begin the same way each round.
5
(if you have a computer or tablet) In Scratch, make a sprite move right 50 steps when you click the flag. Click the flag three times. Then add a go to block and click three times again. What changes?
Without go to, the sprite drifts further right each click. With go to x: y: after the hat block, it starts from the same place every time.