Author | pavankasireddi |
Submission date | 2019-06-09 04:08:31.512487 |
Rating | 1554 |
Matches played | 236 |
Win rate | 14.83 |
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)]