Author | FreqAuthor |
Submission date | 2019-01-12 01:24:07.418550 |
Rating | 6104 |
Matches played | 253 |
Win rate | 60.08 |
Use rpsrunner.py to play unranked matches on your computer.
from collections import defaultdict
import random
if input == "":
output = random.choice("RPS")
my = output
their = ""
allcounts = defaultdict(lambda: defaultdict(int))
else:
their += input
if len(their) >= 3:
allcounts[my[-3]+their[-3]+my[-2]+their[-2]][their[-1]] += 1
counts = allcounts[my[-2]+their[-2]+my[-1]+their[-1]]
if counts["R"] > counts["P"] and counts["R"] > counts["S"]:
output = "P"
elif counts["P"] > counts["S"]:
output = "S"
else:
output = "R"
else:
output = "PSR"[["R", "P", "S"].index(input)]
my += output