v3_hyung

Authorbhyung
Submission date2018-08-25 04:45:05.651848
Rating3223
Matches played281
Win rate33.1

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

Source code:

import random
mem = []
steps = 40
r = "R"
p = "P"
s = "S"

if input == "": # initialize variables for the first round
    output = random.choice([r,p,s])
    rCount = pCount = sCount = 0
elif input == r:
    rCount += 1
    mem.append(r)
elif input == p:
    pCount += 1
    mem.append(p)
elif input == s:
    sCount += 1
    mem.append(s)


if len(mem) < 3 and input != "":
    if rCount > pCount and rCount > sCount:
        output = p
    elif pCount > sCount:
        output = s
    else:
        output = r

if len(mem) > 2:
    rC = pC = sC = 0
    for i in range(len(40)):
        if mem[i] == r:
            rC += 1
        elif mem[i] == p:
            pC += 1
        else:
            sC += 1
    
    if rC > max(pC,sC):
        output = p
    elif pC > sC:
        output = s
    else:
        output = r