Author | bhyung |
Submission date | 2018-08-25 21:50:31.539244 |
Rating | 5187 |
Matches played | 265 |
Win rate | 50.19 |
Use rpsrunner.py to play unranked matches on your computer.
import random
r = "R"
p = "P"
s = "S"
mem = []
if len(mem) < 10:
output = random.choice([r,p,s])
if input != "":
mem.insert(0,input)
else:
mem.insert(0,input)
rr = rp = rs = pr = pp = ps = sr = sp = ss = 0
for i in range(len(mem)-1):
if mem[i] == r and mem[i+1] == r:
rr += 1
elif mem[i] == r and mem[i+1] == p:
rp += 1
elif mem[i] == r and mem[i+1] == s:
rs += 1
elif mem[i] == p and mem[i+1] == r:
pr += 1
elif mem[i] == p and mem[i+1] == p:
pp += 1
elif mem[i] == p and mem[i+1] == s:
ps += 1
elif mem[i] == s and mem[i+1] == r:
sr += 1
elif mem[i] == s and mem[i+1] == p:
sp += 1
elif mem[i] == s and mem[i+1] == s:
ss += 1
if input == r:
if rr > max(rp,rs):
output = p
elif rp > rs:
output = s
else:
output = r
elif input == p:
if pr > max(pp,ps):
output = p
elif pp > ps:
output = s
else:
output = r
elif input == s:
if sr > max(sp,ss):
output = p
elif sp > ss:
output = s
else:
output = r