Author | leowu2017 |
Submission date | 2017-12-05 18:46:12.913530 |
Rating | 1802 |
Matches played | 308 |
Win rate | 16.23 |
Use rpsrunner.py to play unranked matches on your computer.
import random
if not input:
his_len = 5
beat = {'R':'P', 'P':'S', 'S':'R'}
his = [''] * his_len
output = random.choice("RPS")
else:
his = his[1:] + [input]
R_num = (his.count('R'), 'R')
P_num = (his.count('P'), 'P')
S_num = (his.count('S'), 'S')
min_val = min(R_num, P_num, S_num)[0]
min_idx = [x[1] for x in [R_num, P_num, S_num] if x[0] == min_val]
output = beat[random.choice(min_idx)]