Author | FreqAuthor |
Submission date | 2019-01-12 04:31:24.053346 |
Rating | 7479 |
Matches played | 265 |
Win rate | 75.47 |
Use rpsrunner.py to play unranked matches on your computer.
from collections import defaultdict
import random
def highest(S, sub):
i = S[::-1].find(sub[::-1])
if i != -1:
return len(S) - len(sub) - i
else:
return -1
if input == "":
output = random.choice("RPS")
hist = output.lower()
else:
hist += input
for D in range(min(len(hist)//2, 100) - 1, 0, -1):
i = highest(hist[:-2], hist[-2*D:])
if i != -1:
output = "PSR"[["R", "P", "S"].index(hist[i+2*D+1])]
break
else:
output = random.choice("RPS")
hist += output.lower()