Author | msuvakov |
Submission date | 2017-04-30 21:47:57.733240 |
Rating | 6247 |
Matches played | 364 |
Win rate | 60.99 |
Use rpsrunner.py to play unranked matches on your computer.
import random
output = random.choice(["R","P","S"])
if not input:
i=0
beat={'R':'P','P':'S','S':'R'}
output = random.choice(["R","P","S"])
omoves=[]
mmoves=[output]
else:
omoves.append(input)
i=i+1
if i<500:
output = random.choice(["R","P","S"])
else:
hist={}
for i in range(len(omoves)-2):
s=omoves[i]+mmoves[i]+omoves[i+1]+mmoves[i+1]+omoves[i+2]
if s in hist:
hist[s]=hist[s]+1
else:
hist[s]=1
s0=omoves[-2]+mmoves[-2]+omoves[-1]+mmoves[-1]
if s0+"R" in hist:
r=hist[s0+"R"]
else:
r=0
if s0+"S" in hist:
s=hist[s0+"S"]
else:
s=0
if s0+"P" in hist:
p=hist[s0+"P"]
else:
p=0
if r>s:
if r>p:
pred="R"
else:
pred="P"
else:
if s>p:
pred="S"
else:
pred="P"
output = beat[pred]
mmoves.append(output)