Author | kAworu |
Submission date | 2019-05-09 18:59:04.049663 |
Rating | 6005 |
Matches played | 247 |
Win rate | 57.89 |
Use rpsrunner.py to play unranked matches on your computer.
#!/usr/bin/env python
import random
# keep track of the opponent choice history, pick one of them at random and
# beat it. Play a random choice instead 25% of the time.
if input == "":
history = []
output = random.choice(["R", "P", "S"])
else:
history.append(input)
x = {"S": "R", "R": "P", "P": "S"}[random.choice(history)]
y = random.choice(["R", "P", "S"])
output = x if random.randint(1, 4) > 1 else y