Rock, paper scissors is a well known game in the United States. Two players count 1, 2, 3, then each throw down one hand as a rock (closed fist), paper (all fingers out), or scissors (two fingers out).
The winner is as follows:
- Paper beats rock. (Paper covers rock)
- Scissors beats paper. (Scissors cuts paper)
- Rock beats scissors. (Rock crushes scissors)
- If the two are the same it is a tie.
The game
Story: Odin and the Troll will play a game of rock paper scissors.
Pseudocode:
- Odin will count down 3, 2, 1.
- A random number from 0 to 2 (0,1,2) will be selected.
- If the number is 0, Odin will show rock.
- If the number is 1, Odin will show paper
- If the number is 2, Odin will show scissors.
- A random number from 0 to 2 (0,1,2) will be selected.
- If the number is 0, Troll will show rock.
- If the number is 1, Troll will show paper
- If the number is 2, Troll will show scissors.
- Decide the winner
You may find that there are some steps that you haven't figured out the details for yet. Such as how to show the winner and how to manipulate the hands to show rock, paper, and scissors. We will use step wise refinement to work out all of the details.
End of lesson, Next lesson: