Snap! Project 5: Simon Says

Description: Create an interactive game using the Finch as a controller.

Programming Concepts: Using lists, generating random numbers, using complicated systems of if statements

Difficulty: Advanced

Approx. Time: 30 Minutes

Programming steps


In this game, the program will tell the player how to orient the Finch. If the statement starts with "Simon says", then the player must follow the instruction. For example, if the program says "Simon says left wing down", then the player must hold the Finch on its side with its left wing pointed down. If the statement does not start with "Simon says", then the player should not follow the instruction.


1. Let's start with a "When space key pressed" block to trigger the program.

2. Go to the "Sensing" category and find the "Finch Orientation" block. Tilt the Finch in some direction and then click the "Finch Orientation" block. You should get outputs like "Beak Up", "Left Wing Down", and "Level".

3. In order for the program to tell the user how to orient the Finch, we need to give the program a list of all the possible Finch orientations. The program will then be able to pick a random entry from that list and display it (following the words "Simon says"). Go to the "Variables" category and click "Make a variable".

4. Name the list "Commands".

5. Use a "set" block and a "list" block to set the Commands variable to equal a new list.

6. Use the right arrow to add more spaces to the list until there are 6 empty spaces. Then fill the spaces with the following commands:

Beak Up

Beak Down

Left Wing Down

Right Wing Down

Upside Down


NOTE: It is important that you enter the commands exactly as shown. If you are using Google Chrome, you may be unable type spaces into Snap! and should copy and paste the above commands into the list. Use Ctrl+C for copy and Ctrl+V for paste.

7. Add a forever loop below the set block so we can give each game multiple "Simon says" statements.

8. We now want to pick an item from the list randomly. We need the program to remember which item was picked so that we can later see if the user responded correctly. We can create a new variable to do this. Name the variable "TargetOrientation".

9. Now set the TargetOrientation to be an item from the list. Place an "item 1 of Commands" block within a "set TargetOrientation to" block.

10. To select the item randomly, go to the "Operators" category and insert a "pick random" block into the slot where the 1 is.

11. Make the random number be a value from 1 to 6.

12. To make the computer say the command, grab a "say" block from the "Looks" category.

13. Place a "join" block from the "Operators" category inside the "say" block.

14. Type "Simon Says " (with the extra space at the end) in the first part of the join block and put a TargetOrientation variable block in the second part.

15. Connect a "wait 1 secs" block below the "say" block to give the user time to orient the Finch. Change the time to 2 seconds.

16. If the Finch Orientation matches the TargetOrientation, the user responded correctly and the LED should flash green. If not, the game ends and the LED should flash red. Add an if/else statement that compares the TargetOrientation to the value of the Finch Orientation block.

17. In the if section, make the LED flash and the Finch buzz using the following block configuration:

18. In the else section, add these blocks to make the LED flash red:

19. To make the game end, go to the "Control" category and add a "stop all" block to the end of the else section.

20. Select "this script" instead of "all" from the stop block.

21. Run the program and try it out! The game should be playable, but it still could use some adjustments. Let's make the program keep track of how many commands the user responds to correctly. The computer will then announce this score at the end of the game.

22. Create a new variable named "Score".

23. When the program starts, set Score to 0.

24. Each time the Finch is oriented correctly, increase the Score by 1.

25. At the end of the game, the computer should say "You got # in a row!", where # is the player's score. Add a "say" block from the "Looks" category before the "stop" block.

26. Connect a "join" block (from "Operators") to the "say" block.

27. Click the right arrow to make the block have 3 slots. This will let us join 3 pieces of text together.

28. In the first section, type "You got ". It is important to have a space after the word "got".

29. In the second section, connect a "Score" block from the "Variables" category.

30. Type " in a row!" into the third section.

31. Run the program and the computer should announce the score at the end of the game.

Skilled players might find the game too easy after a while and get bored. To make the game more interesting, we can make the difficulty gradually increase. Instead of giving the user 2 seconds to orient the Finch, we can make this time smaller as the user's score increases.

32. Find the "wait 2 secs" block below the first "say" block and add a "-" block from "Operators" and a "Score" block from "Variables" in the following arrangement:

33. This will make the time get much smaller, but too quickly. Divide the score by 10 to make the increase in difficulty more gradual.

34. The game should be substantially more difficult now. If you think it is too difficult, simply increase the number that Score is being divided by.

Trick Statements

In a real game of Simon says, part of the challenge is avoiding trick statements that do not begin with the phrase "Simon says". This section shows how to add this feature to your program.

1. Create a new variable called "TrickStatement" to keep track of if we are trying to trick the player by using a phrase that does not begin with "Simon Says".

After we set the "TargetOrientation" to a random orientation, we should set "TrickStatement" to 1 if we will try to trick the player and 0 if the statement is not a trick. We want most of our statements to not be trick statements, so TrickStatement should be set to 0 most of the time.

2. Add the following if statement before the first "say" block to set "TrickStatement" to 1 one fifth of the time:

3. If "TrickStatement" equals 1, we should exclude the text "Simon Says ". Replace the first "say" block with the following if statement to achieve this:

4. All we have to do now is determine if the user responded correctly. There are two ways that the user could be correct: one for when the statement was a trick and one for when it was not a trick. Attach an "or" block to the "if" to handle these two cases.

5. If the TargetOrientation is the same as the Finch Orientation, and the statement was not a trick, the user was correct. Use the following blocks to tell the program this:

6. Alternatively, if the statement was a trick, but the user did not fall for it, the user also responded correctly. Use these blocks:

The program is done! Great work!

Example file

This file was created with the Birdbrain Robot Server. Use this utility to convert it to a form that can be used with the Chrome Finch connection app.