# Rock paper scissors

Everyone knows the game rock paper scissors. How cool would it be if you programmed a gaming computer which shows you one of those options every time you shake it!

Shake the micro:bit to see what it chooses. Press A when you win, press B when the micro:bit wins.

You’ll be learning:

• How to use variables.
• How to use the block “choose random”. How to use and adjust the “if...block.

### ORIENTATION

Take a look at the example and consider the following questions:

What should I do?
What are the goals?
What are the expectations?
What do I still have to discover?

### PREPARATION

View the steps at 'perform'. Then answer the following questions:

• Which steps should I follow?
• Which steps can I follow?
• How much time do I need?
• What tools do I need?

### PERRFORM

Do the steps one by one. Do you not remember how to do it? View the hints or download the solution.

## Rock paper scissors

First, create three signs: a piece of paper, a rock and a pair of scissors. Make sure they fit on a 5x5 LED screen!
These signs will appear on the screen when you shake the micro:bit.

## De micro:bit decides

You’ll need an “if ... then...” button. You can find some more information about these blocks below.

We have used the “if...then...else” block a couple of times in Scratch.
You will have noticed that Scratch sometimes wants to stipulate a new condition for the “else” function. You would then have to take a new block in Scratch, but we can also do this in a different way.
You will notice a plus sign on the bottom left of the screen when you drag an “if...then” block to your field of action. Click on that.

You can design your own block now. Every time you click on the plus sign another “else...if” condition will be added.
You can delete the condition by clicking on the minus sign.

HOW DO I PICK A RANDOM DRAWING?
You need a building block that chooses a number at random. You can find one in the group called “math”.

### HOW CAN I REMEMBER THAT RANDOM NUMBER? You will have to keep the random number in a variable. You can find this in the group “variables”.

Make a variable. Choose a suitable name. We gave the variable the name: Choose

So what next? We have to set up the variable so that it can choose a random number. You can put the two blocks together.

We have to set up the system so that every time you shake our variable will become 0,1 or 2.
For the final piece of the puzzle, we need to link the numbers to a drawing. IF... ITEM=0 THEN
Do you know which blocks you are going to need? Well done! Check the next page.

## Playing against the Micro:Bit

We want you to play against the Micro:Bit. Every time you shake, you need to make a choice for yourself. If you win, you press A and a fun message will pop up. If the Micro:Bit wins, you press B and a sad message will pop up. Will you get to it?

## Keeping score

We have to keep score to finish the game. If you win, you will get a bonus point. If you lose, you will lose a point.
Make sure that you can see the score.

Beware, a negative score is also possible. This cannot happen with the ‘score’ from the group “game”. If you want a negative variable, you will have to create one.

Make a new variable “score”.
Will you make sure that you can put the score on 0 when pushing the buttons A and B simultaneously?

### REFLECT

Look back at the project you just made. Ask yourself the following questions:

Does the program work as I expected? Why / why not?
What works well?
What works less well?
How can I approach it differently?