Project 13

Rock, Paper, Scissors

Few recess games are as familiar or fast as Rock, Paper, Scissors. Using only your hands, you and an opponent randomly choose an object and reveal your choice at the same time. Based on the choices, one competitor wins, and one loses: Rock beats scissors, paper beats rock, and scissors beat paper. If both competitors choose the same object, the game is a draw (tie).

In this project, you build your own Rock, Paper, Scissors game with player versus computer. The game uses compound conditionals to determine the winner of each round. A compound conditional has an if-then plus conjunctions (and, or, not) in the code. This code format is used when more than one condition must be met in order for a consequence to happen. “If it is Monday and it is 8 a.m., then I ride the bus to school.” If the player chooses rock and the opponent chooses scissors, rock beats scissors (player wins).

Brainstorm

You can make rock, paper, scissors into any game in which players choose three objects for comparison. The key is that each object must be able to win against another object, and also lose against the third object. What will your game feature?

  • Pop stars, such as Beyoncé, Justin Timberlake, and Selena Gomez
  • Pokémon characters, such as Pikachu, Squirtle, and Snowball

The rules of rock, paper, scissors are shown in Figure 13-1. Remember that if both competitors choose the same object, the game is a draw.

“Rock-paper-scissors” by Enzoklop - Own work. Licensed under ...

Get Coding For Kids For Dummies now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.