#K94312. Rock, Paper, Scissors Game Simulation
Rock, Paper, Scissors Game Simulation
Rock, Paper, Scissors Game Simulation
This problem simulates a game of Rock, Paper, Scissors. In this game, the player competes against a virtual opponent using pre-determined moves. For each round, you are given two moves: the player's move and the opponent's move. The rules of the game are as follows:
\(\text{rock} \text{ beats } \text{scissors},\quad \text{scissors} \text{ beats } \text{paper},\quad \text{paper} \text{ beats } \text{rock}\).
If both moves are the same, the outcome is a draw. The game continues round by round until the word exit
is given as input. For each valid round, output the round result (win
, lose
, or draw
) on one line, then the current score in the format Player: X Computer: Y
on the next line. When exit
is input, output the final score in the format Final Score - Player: X Computer: Y
and terminate the program. In case of invalid input (i.e. if the player's move or the computer's move is not one of rock
, paper
, scissors
), print an error message and do not update the scores.
inputFormat
The input is read from standard input (stdin
). The input consists of multiple lines. Each line is either:
- a pair of strings separated by a space representing the player's move and the computer's move, or
- a single word
exit
(without quotes) which indicates the end of input.
Valid moves are rock
, paper
, and scissors
.
outputFormat
For each valid round, output two lines:
- The first line is the outcome of that round:
win
,lose
, ordraw
. - The second line is the current cumulative score in the format:
Player: X Computer: Y
, whereX
is the player's score andY
is the computer's score.
If an invalid input is encountered, output Invalid input, please enter rock, paper, scissors or exit.
(without quotes) and ignore that round.
When the input is exit
, output a final line with the score in the following format: Final Score - Player: X Computer: Y
.
rock scissors
exit
win
Player: 1 Computer: 0
Final Score - Player: 1 Computer: 0
</p>