Lab 1:


There are times when you will want blocks to
repeat. Instead of duplicating blocks and ending
up with a long script that might be confusing, there
are looping control blocks that you can wrap
around the script you want to repeat.
› “forever” – loops until the program ends. This is basically an
infinite loop as it goes on forever.
› “repeat ()”- loops the specified number of times.
› “repeat until < >” Repeat until the condition is True.
You will use predicate blocks which can be found in the
Operator Palette
Let’s look at the “repeat until”
block a bit closer.

› Just like REPEAT, it will do everything inside the C-
shaped block a certain number of times.

However before it starts the loop each time, it
checks to see if the condition (x > 5) is true.
When this is condition is true, it will not repeat
again.

Step 1 – Welcome Player, build Script!

Step 2 – Inform Player about their guess

Step 3 – Allow player to choose max value

Step 4 – Count number of guesses

Step 5 – Report number of guesses to
player

Remember from Lab1, when we created
a script for the sprite to ask our name!

Let’s look at our algorithm…
We want to give the player more
information if they don’t guess correctly.
 Have the sprite tell the player if the
secret number is bigger or smaller than
the number that they guessed.


Work with your neighbor to add to your
script…

Remember there is more than one way
to do this!
Change your code so that the player
choose the max value, instead of the
sprite choosing a number between 1
and 10
 Use this maximum number as the highest
number that the sprite will choose.


Hint: Make a new variable for “max”
value

Make a variable for “max”
Now let’s keep track of how many
guesses it takes before the player
guesses the right number.
 You will need a new variable for this task
and will need to add to it every time a
guess occurs.


When the player guesses the secret
number tell them how many guesses it
took, and congratulate them using their
name.

Hint: Use previous variables!

The goal of this Expanded Guessing
Game (we’ll call it, version 2.0) is to
make sprites that play the game smarter!
› Create two sprites to play the game
 Guide sprite
 Guesser sprite
› Create a list
› Follow the 5 steps outlined in Manual 3.