Skip to Main Content
It looks like you're using Internet Explorer 11 or older. This website works best with modern browsers such as the latest versions of Chrome, Firefox, Safari, and Edge. If you continue with this browser, you may see unexpected results.

Robots @ SIT

Get hold of one of the available Robots at SIT Library and start your robotics journey today!

Description

Required Knowledge:

LED display, Buzzer sound, Loops, Conditional statements, Lists, Variables, Randomness, Timers

Application:

While Simon Says is a very simple game, the basic logic and thinking skills built up in doing this activity are a must when developing games. Game developers must think about game mechanics, rewards, player engagement and level design, and must constantly test and refine the game to fix bugs or add in new features.

 

Simon Says - Basic

Write a program that asks the player to orient the Finch a certain way. For example, the program might tell the user, “Simon Says: Finch Beak Up.”

After giving a command, the Finch should wait until the player makes the right move. When the user places the Finch in the correct orientation, the Finch should blink its beak for 3 secs. Then the Finch should give another command. Your game should cover at least three of the possible orientations.

Python Hint: “!=” means not equal to

 

Snap!:

1. Use a say block to tell the user to place the Finch in a certain orientation. An example is provided below.

2. Use a wait until block that triggers the blocks below only when the Finch is in the correct orientation.

3. Use a repeat block that contains Finch Beak and wait blocks inside that cause the Finch beak to blink for 3 seconds.

4. Repeat steps 1-3 for different orientations.

 

Python:

1. Import the sleep() function from the time library using "from time import sleep".

2. Use the print() function to print out a message for the user to put the Finch in a certain orientation. For example, print('Simon Says: Finch Beak Up.').

3. Use a while loop that breaks when the Finch is put into that position.

4. Within the while loop, use a sleep(0.1) statement to make the program pause until the Finch is placed in the correct position.

5. When the while loop breaks, use a for loop to make the Finch beak blink for 3 seconds.

6. Repeat steps 2-5 for different orientations.

 

 

Simon Says - Enhanced

In this activity, you will make a more complex Finch version of the game Simon Says. The Finch will give the user random commands and count how many the user successfully follows.

Your program should meet the following requirements:

· For each round of the game, the computer should tell the user to move the Finch to a particular orientation. The Finch orientation for each round should be chosen randomly.

· The game should wait until the user places the Finch in the correct orientation.

· When the user places the Finch in the correct position, their score should increase by 1.

· The Finch’s beak and buzzer should indicate when the user scores a point.

 

Extension

Instead of waiting until the user places the Finch in the correct position, modify your program so that the program waits 5 seconds and then checks if the user has the Finch in the correct position. If it is, then the user gets a point. If not, the Finch lights and buzzer should indicate that they are wrong. Then use a variable for the wait time so that the game gradually gets harder!

 

Snap!:

1. Create 3 variables: waitTime, totalScore and x

2. Set waitTime = 5 and totalScore = 0

3. Create 2 lists: messagesList and orientationsList. They should contain the messages to be printed to the screen to inform the user what orientation to put the Finch to, and the 6 different orientations (Level, Upside Down, Tilt Left, Tilt Right, Beak Up, Beak Down) of the Finch respectively.

4. Use a repeat until block that repeats until button A is pressed.

5. Within the repeat until block, set x to a random number between 1 and 6.

6. Use the say block to print to the screen the message in messagesList corresponding to the value of x.

7. Use the reset timer block to reset the value of the timer.

8. Use a wait until block that waits until the value of the timer exceeds the value of waitTime or the finch is in the correct orientation.

9. Use an if-else block. The if block is triggered when the timer value is smaller than or equal to the waitTime value. It will print "Correct!" to the screen and increase the value of totalScore by 1. Then, use the Finch beak block to light up the Finch beak, followed by the Finch Play Note block to play a note of your choice.

10. In the else block, print "Wrong!" to the screen. Light up the Finch beak with a different colour and play a different note from step 9.

11. After the if-else block, use a wait block to pause the program for a second before using the stop all block to turn off the Finch beak and stop the buzzer.

12. Use an if block that triggers if the value of waitTime is larger than 0.6 seconds. Within this if block, decrease the value of waitTime by 0.1 seconds.

13. After the main repeat until block, use a say block to print to the screen the total score.

 

Python:

1. Import the time() and sleep() functions from the time library, using 'from time import sleep,time'. Import the random library using 'import random'.

2. Create 2 lists called messages and orientations. They should contain the messages to be printed to the screen to inform the user what orientation to put the Finch to, and the 6 different orientations (Level, Upside down, Tilt left, Tilt right, Beak up, Beak down) of the Finch respectively.

3. Declare 3 variables: totalscore = 0, waitTime = 5, wrong = 1

4. Use a while loop that breaks when button A is pressed.

5. Within the while loop, declare a variable x that generates a random integer between 0 and 5.

6. Print the message in the messages list corresponding to x to the screen using "print(messages[x])".

7. Use the startTime = time() statement.

8. Within the first while loop, use another while loop that breaks when the total reaction time of the user exceeds the value of waitTime. This is done using "while time()-startTime <= waitTime".

9. Within the second while loop, use an if statement that triggers when the orientation of the Finch is equal to the correct orientation. This is done using "if bird.getOrientation() == orientations[x]".

10. Within the if statement, print "Correct!" to the screen. Add one to the totalscore variable, and make the Finch beak light up, as well as play a note of your choice.

11. Use the sleep(1) statement to leave the finch beak on for a second before setting the score of "wrong" to 0.

12. Use the break statement to break the second while loop.

13. When the second loop breaks, use an if-else statement where the if statement is triggered if the value of "wrong" is 1. This if statement will print "Wrong!" to the screen, and light up the Finch beak with a different colour and play a different note from step 10. Include a sleep(1) statement afterwards to leave the finch beak on for a second.

14. The else statement will just set the value of "wrong" back to 1.

15. After this first if-else statement, use the bird.stopAll() function to switch off the Finch beak and turn off the buzzer.

16. Use an if statement that triggers when waitTime is larger than 1. Within this if statement decrease the value of waitTime by 0.1 seconds.

17. When the main while loop breaks, print the total score to the screen.

 

 

Sample Codes