Author | leowu2017 |
Submission date | 2017-12-05 18:46:12.889610 |
Rating | 1590 |
Matches played | 305 |
Win rate | 14.43 |
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)]