Author | FreqAuthor |
Submission date | 2019-01-12 01:14:21.389806 |
Rating | 5494 |
Matches played | 247 |
Win rate | 56.68 |
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) > 1:
allcounts[my[-2]+their[-2]][their[-1]] += 1
counts = allcounts[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