Author | ... |
Submission date | 2019-12-13 14:19:08.211402 |
Rating | 3650 |
Matches played | 211 |
Win rate | 36.02 |
Use rpsrunner.py to play unranked matches on your computer.
import random
wbt = {"R":"P","P":"S","S":"R"}
if not input:
output = 'S'
history = 'S'
else:
history += input+'O'
l = 1
while history.find(history[(l*-3):]) != len(history)-(l*3):
l+=1
l-=1
li = [i for i in range(len(history)) if history.startswith(history[(l*-3):], i)]
del li[-1]
if len(li) > 0:
output = wbt[history[random.choice(li)+(3*l)]]
else:
output = wbt[history[random.randint(0,len(history)/3-1)*3+1]]
history += output