pxt-calliope/olddocs/js/lessons/number-psych/quiz.md
2016-11-01 17:44:37 -07:00

3.0 KiB

number psych quiz

a 4-player game in which each player must outwit his opponents.

Name

Directions

Use this activity document to guide your work in the number psych console tutorial and the number psych controller tutorial.

Answer the questions while completing the tutorial. Pay attention to the dialogues!

Questions 1-9 are concerned with 'number pysch console tutorial'

1. Create a 'collection of options' and save them in a local variable named 'options'.


2. Add the options '1', '3', and '5' into the local variable 'options'.



3. Create a collection of scores and add four values of '0' into the collection.



4. Write the code that reads a byte that indicates a controller is asking for a player number. (Don't bother checking if the byte received is 255.) Next, write the code that transfers the player number to the controller.




5.Write the code that transfers the three options.



6.Write the code that requests each player to send their choice in the player order number. Don't worry about reading their choice. (Hint: look at the four loop with 'k' as the index.)




7.Write the code to create two collections. One collection ("choices") stores all the choices, while the other collection ("has common") stores whether or not the choice is unique. (If the choice is not unique, then "has common" will be set to true for that particular choice.)



8. Write the code that compares each of the choices with each other. If the two choices are the same, then set the appropriate value inside 'has common' to true. (Hint: look at the for loops with 'l' and 'n' as their indexes.)







9. For each value inside 'has common', transfer a '1' if there is a match and transfer a '0' if there isn't a match. Add a pause of 100 milliseconds at the beginning of each transfer.)




Questions 10-14 are concerned with 'number pysch controller tutorial'

10. Write the code that asks for a player number if button 'A' is pressed on the BBC controller @boardname@.



11. Write the code that adds the three transferred options to the "options" collection. (Hint: look at the for loop with 'k' as the index.)




12. Write the code that detects when button 'B' is pressed. Inside this condition, if 'game mode' is 2, set 'game mode' back to 1 and plot a waiting image.



13. Create a while loop that first reads which controller the console @boardname@ is requesting data from. Plot a waiting image, and then write an IF statement to check if the request corresponds to the controller. (Don't worry about writing anything inside the if statement).




14. Write the code that displays an "X" on the @boardname@ if 'result' is 1. Otherwise, display a "check mark".