Presentation is loading. Please wait.

Presentation is loading. Please wait.

Use logic to teach the computer how to play a game

Similar presentations


Presentation on theme: "Use logic to teach the computer how to play a game"— Presentation transcript:

1 Use logic to teach the computer how to play a game
Rock Paper Scissors Use logic to teach the computer how to play a game

2 Rock Paper Scissors Comes from a Japanese game called “jan-ken”
It’s a game usually played by two people, where players make one of three shapes with their hands at the same time. The "rock" beats scissors, the "scissors" beat paper and the "paper" beats rock; if both players throw the same shape, the game is tied.

3 Objective To complete a Rock Paper Scissors game using BYOB that allows a person to play against the computer. The game has been started for you on the compsci drive in the Designing Tech folder.

4 Directions Start BYOB Open the RockPaperScissors_YourName file from the Compsci drive in the Designing Tech folder. Save it to your H: drive with your own name.

5 Some information It’s easier for a computer to work with numbers
For this program, the computer will assign a number to each choice ROCK=0 PAPER=1 SCISSORS=2 To choose the winner you have to compare the computer’s choice with the player’s choice.

6 Try the program It’s not finished yet.
Choose J, K or L and see what happens Is it the same every time? The only part missing in this program is the code to decide who wins. That’s your job. This part is missing

7 How will you decide the winner?
Algorithm 1 If player1 chooses rock.. If computer chooses rock it’s a tie If computer chooses scissors, then player 1 wins because rock smashes scissors If computer chooses paper then computer wins because paper covers rock. Algorithm 2 If player1 chooses rock and computer chooses rock it’s a tie If player1 chooses rock and computer chooses scissors, player 1 wins because rock smashes scissors If player1 chooses rock and computer chooses paper then computer wins because paper covers rock. Can you see how these 2 algorithms are different but they both do the same thing?

8 What do the conditions look like?
Algorithm 1 If player1 chooses rock.. If computer chooses rock it’s a tie Algorithm 2 If player1 chooses rock and computer chooses rock it’s a tie Can you see how these 2 algorithms are different but they both do the same thing? Choose the algorithm that makes the most sense to you.

9 Answer questions on Edline
Use BYOB and the Rock Paper Scissors program to answer the questions. If you can’t get into your Edline account, ask the sub for a paper to write your answers on.

10 Finish the program Complete the code
It’s in the computer sprite script Fix the part after when I receive determine winner. Make it say who wins and why Replace this part

11 Challenge Add 3 more variables and count: How many rounds were played
How many times the computer wins How many times the player wins


Download ppt "Use logic to teach the computer how to play a game"

Similar presentations


Ads by Google