rps_pavankasireddi

Authorpavankasireddi
Submission date2019-06-09 04:08:31.512487
Rating1495
Matches played207
Win rate14.49

Use rpsrunner.py to play unranked matches on your computer.

Source code:

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)]