The classic game for two.
Rock paper scissors is a hand game originating from China, played between two people, in which each player simultaneously forms one of three shapes with an outstretched hand. These shapes are “rock” (a closed fist), “paper” (a flat hand), and “scissors” (a fist with the index finger and middle finger extended, forming a V).
The rock beats the scissors. The paper beasts the rock and the scissors beats the paper. This version of the game is played between a user and the computer over five rounds. The first player to win five rounds wins the game.
⭐⭐⭐
Write a program that simulates the game rock, paper, scissors to be played by the user against the computer.
Remember to add a comment before a subprogram, selection or iteration statement to explain its purpose.
get_player_choice that:convert that:rps.This is a helper function that converts a single character input from the user (their choice) into something more readable for output.
cpu_choice that:who_won_round that:player and cpu which are the two choices made: “r”, “p” or “s”.play_game that:main program so that:play_game subprogram is called.player score: 0 cpu score: 0
Enter rock, paper, scissors (r/p/s): g
Enter rock, paper, scissors (r/p/s): h
Enter rock, paper, scissors (r/p/s): r
player's rock beats cpu's scissors
player score: 1 cpu score: 0
Enter rock, paper, scissors (r/p/s): p
cpu's scissors beats player's paper
player score: 1 cpu score: 1
Enter rock, paper, scissors (r/p/s): s
cpu's rock beats player's scissors
player score: 1 cpu score: 2
Enter rock, paper, scissors (r/p/s): r
rock - rock - it's a draw.
player score: 1 cpu score: 2
Enter rock, paper, scissors (r/p/s): p
player's paper beats cpu's rock
player score: 2 cpu score: 2
Enter rock, paper, scissors (r/p/s): s
scissors - scissors - it's a draw.
player score: 2 cpu score: 2
Enter rock, paper, scissors (r/p/s): r
rock - rock - it's a draw.
player score: 2 cpu score: 2
Enter rock, paper, scissors (r/p/s): p
cpu's scissors beats player's paper
player score: 2 cpu score: 3
Enter rock, paper, scissors (r/p/s): s
cpu's rock beats player's scissors
player score: 2 cpu score: 4
Enter rock, paper, scissors (r/p/s): r
cpu's paper beats player's rock
CPU WINS!