Author | Chia |
Submission date | 2020-01-08 10:14:15.422024 |
Rating | 5349 |
Matches played | 206 |
Win rate | 53.88 |
Use rpsrunner.py to play unranked matches on your computer.
import random
# Initialise history with one of each choice
if input == "":
history = list(range(3))
# Beat a random throw from my own history
choice = (random.choice(history) + 1) % 3
# Update history
history.append(choice)
# Convert (0, 1, 2) to (R, P, S) and output
output = "RPS"[choice]