Author | bhyung |
Submission date | 2018-08-25 03:44:35.345533 |
Rating | 1851 |
Matches played | 275 |
Win rate | 20.0 |
Use rpsrunner.py to play unranked matches on your computer.
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) < 5 and input != "":
if rCount > pCount and rCount > sCount:
output = r
elif pCount > sCount:
output = p
else:
output = s
if len(mem) > 5:
rC = pC = sC = 0
for i in range(5):
if mem[i] == r:
rC += 1
elif mem[i] == p:
pC += 1
else:
sC += 1
if rC > max(pC,sC):
output = r
elif pC > sC:
output = p
else:
output = s