v2_hyung

Authorbhyung
Submission date2018-08-25 04:28:23.931157
Rating3818
Matches played258
Win rate32.56

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

Source code:

import random
mem = []
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(mem)):
        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