Rock-Paper-Scissors
Time limit15sMemory limit1024 MB
Play rock-paper-scissors against 10 fixed programs over stdin and stdout, and maximize your total score until the opponent sends L.
- Level
Medium4 of 10
- Topics
- Simulation, Game theory, String matching
- Solved
- No attempts yet
Problem
The rock-paper-scissors game is played as follows: Two players simultaneously pick their moves as 'rock', 'paper', or 'scissors'. When both pick the same move, they each get zero points. When they pick different moves, the rock beats the scissors, the scissors beat the paper, and the paper beats the rock. The player who picked the winning move gets and the loser points. A match consists of a number of moves whose points are added. Thus, the sum of points of the two players at the end of a match will always be zero.
Many rock-paper-scissors competitions have the main goal of guessing the opponent's strategy and playing against it.
The jury has implemented 10 simple programs that play rock-paper-scissors. Write a program to play against them and score as many points as possible.
Output
Your program is started anew for each opponent. Your program should write its move, followed by a newline, to standard output, then read the opponent's move from standard input. Each move is one capital letter: K (rock), P (paper), or R (scissors). A judge program receives the moves of the jury's program in the same way and keeps track of the score. The end of the match is signaled by L as the opponent's move, and your program must terminate immediately after that.