Author | jmc |
Submission date | 2020-01-23 16:55:19.233065 |
Rating | 1988 |
Matches played | 202 |
Win rate | 19.8 |
Use rpsrunner.py to play unranked matches on your computer.
import random
if input == "":
round = 1
firstMove = random.choice(["R", "P", "S"])
opp_history = ""
my_history = ""
beatby = {}
beatby["R"] = "P"
beatby["P"] = "S"
beatby["S"] = "R"
opp_history += input
if round < 7:
output = firstMove
else:
pattern = opp_history[-6:]
if pattern[-6:-3] == pattern[-3:]:
output = beatby[pattern[0]]
else:
if pattern[-2] == pattern[-1]:
output = pattern[-1]
else:
if pattern[-4:-2] == pattern[-2:]:
output = beatby[pattern[-2]]
else:
if round % 2 == 0:
output = firstMove
else:
output = pattern[-3]
my_history += output