Getting Started Guide

CLASS 4
58
Commentary
Mole game question 1 commentary
Did you get it to decrease your time by 0.1 when you accumulate 10 points to ‘Score’? was it activated correctly? If
it did, just take this commentary as consultation and move on to the next page. If it didn’t work out as you wanted,
use the script below.
Combine the script above into the beginning of the 'infinite repeat’ block and run the program. If the ‘Score’
becomes the multiple of 10, everything else becomes 0 when it is divided by ten. Therefore, every time ‘Score’
becomes 10, 20, 30,… rest divided by 10 becomes 0 so the script inside the ‘If~’ block is activated. The script inside
the block means that subtract 0.1 from the currently saved ‘Timeout’ variable value and save it again. Therefore,
whenever the ‘Score’ becomes 10,20,30,… the ‘Timeout’ will become 1, 0.9, 0.8,.. The numerical change of ‘Time-
out’ variable is shown in the screen on the main cell on your right.
If you follow the script above, you will notice something odd. You will see the variable value of ‘Timeout’ will start
at 0.9 instead of 1. This is because if the ‘Score’ starts with 0 and when divided by 10, it will give 0 again. Therefore,
to satisfy the condition, the variable value of ‘Timeout’ starts with 0.9.
You can solve this problem using the script above. Connect the condition saying “’Score’ must be greater than 0”
with ‘and’ block so that the ‘If~’ block is only activated if both condition is satisfied. If you code it like this, you can
avoid the first value being 0.9.
The whole script can be found at http://www.robotori.com/web_eng -> Moretips -> Manual ->EDU ->Logic
boost CODING CLASS 4 ->download whole script