The rule is simple. Rock beats scissors, scissors beat paper, and paper beats rock. Code the rules, create visuals, and bring the thrill of this classic game to life.
Rock Paper Scissors is a two-player game where each player simultaneously chooses one of three options: rock, paper, or scissors. As a test case, create the game such that it is playable between a computer and a human player.
Rock beats scissors: If one player chooses rock and the other player chooses scissors, the player who picked rock wins. Rock smashes or breaks scissors. Scissors beat paper: If one player chooses scissors and the other player chooses paper, the player who picked scissors wins. Scissors cut through paper. Paper beats rock: If one player chooses paper and the other player chooses rock, the player who picked paper wins. Paper wraps or covers rock. If both players choose the same option, it results in a tie or a draw. For example, if both players choose rock, it is a tie. No points are awarded, and the game moves on to the next round.
The game can be played in a single round or multiple rounds. A typical way to determine the winner is by keeping score. Each player starts with a score of zero, and after each round, the winner of that round earns one point. The game can continue for a predetermined number of rounds, and at the end, the player with the highest score will be the overall winner.
It’s always Input, Process, Output.
- Let you start by making the computer randomly choose between R, P, or S.
- Ask a user to choose between R, P, or S.
- Evaluate the state of the game: who would win or whether the game is a tie
- Announce the state of the game
- These are merely starting points. Once you build the fundamentals, let you take it up a notch and reflect what you have in mind.
- Submission of this challenge, just like all of the Weekly Coder’s challenges, is to be submitted within 36 hours after its post. And so, Sunday morning 12:00 LT.