Author | TheCrouchMode |
Submission date | 2016-01-15 12:41:19.976722 |
Rating | 5842 |
Matches played | 456 |
Win rate | 57.89 |
Use rpsrunner.py to play unranked matches on your computer.
import random
import collections
size = 300
try:
prev
except NameError:
prev = collections.deque([])
output = ""
if input == "":
for i in range(size):
prev.append(random.choice(["R", "P", "S"]))
output = random.choice(["R", "P", "S"])
else:
prev.appendleft(input)
prev.pop()
guess = random.choice(prev)
if guess == "R":
output = "P"
elif guess == "P":
output = "S"
elif guess == "S":
output = "R"