v4_hyung

Authorbhyung
Submission date2018-08-25 19:19:48.731694
Rating1946
Matches played269
Win rate17.47

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

Source code:

import random
in_mem = []
out_mem = []

r = "R"
p = "P"
s = "S"

if input == "":
    output = random.choice([r,p,s])
    out_mem.insert(0,output)
elif input == r:
    in_mem.insert(0,r)
elif input == p:
    in_mem.insert(0,p)
elif input == s:
    in_mem.insert(0,s)

if len(in_mem) > 0:
    r_win = p_win = s_win =0
    for i in range(len(out_mem)-1):
        if r == out_mem[i] and s == in_mem[i]:
            r_win += 1
        elif p == out_mem[i] and r == in_mem[i]:
            p_win += 1
        elif s == out_mem[i] and p == in_mem[i]:
            s_win += 1
    
    if r_win > p_win and r_win > s_win:
        output = r
        out_mem.insert(0,output)
    elif p_win > s_win:
        output = p
        out_mem.insert(0,output)
    else:
        output = s
        out_mem.insert(0,output)