Author | JMIS |
Submission date | 2020-01-23 16:51:38.199959 |
Rating | 3196 |
Matches played | 209 |
Win rate | 32.54 |
Use rpsrunner.py to play unranked matches on your computer.
idx = { "R": 0, "P": 1, "S": 2 }
if input == "": # initialize variables for the first round
counts = [[[0] * 3] * 3] * 3
prev_input = ''
prev_prev_input = ''
output = 'P'
if prev_prev_input:
counts[idx[prev_prev_input]][idx[prev_input]][idx[input]] += 1
s = 0
m = 0
for i in range(0, 3):
if counts[idx[prev_prev_input]][idx[prev_input]][i] > m:
s = i
m = counts[idx[prev_prev_input]][idx[prev_input]][i]
output = ['P', 'S', 'R'][s]
prev_prev_input = prev_input
prev_input = input