Rock-Paper-Scissors Rock-Paper-Scissors is a hand game usually played between two people to see who goes first or who gets first choice. Each player forms one of three shapes with an outstretched hand. The shapes are rock (a simple fist), paper (a flat hand), and scissors (a fist with the index and middle fingers forming a V), as shown in Figure 2-8. To start the game, the players usually count aloud 1-2-3, each time raising one hand in a fist and swinging it down on the count. On 3, both players “throw” by forming their hands in the shape they chose. Finally, determine who wins. There are only three possible ways to win: Rock beats scissors. Paper beats rock. Scissors beats paper. If there is a tie, play again. The problem-solving method can be used to write an algorithm to play this game. Understand the Problem First, state the problem. In this case, the problem is the need to explain the rules of Rock-Paper-Scissors so the game can be played. If you understand the problem, continue to the next step. Devise a Plan To explain the game to new players, the rules can be written out. This also provides a consistent source to consult in case there are future questions. After the rules are written, the game can be played based on them. Goodheart-Willcox Publisher iko/Shutterstock.com Figure 2-8. Writing an algorithm for playing the game Rock-Paper-Scissors. Problem: Play the game Rock-Paper-Scissors. Solution: Write out the rules for the game so players know how to play the game. Algorithm: 1. Choose what object you will play: rock, paper, or scissors. 2. Agree with second player that it is time to play. 3. Count to three. 4. Immediately both players “throw” (show their hands). 5. Evaluate the outcome. Rock beats scissors, scissors beats paper, and paper beats rock. Copyright Goodheart-Willcox Co., Inc. Chapter 2 Solving Problems 35
Previous Page Next Page