Author | Linch |
Submission date | 2020-01-02 01:28:17.754938 |
Rating | 5644 |
Matches played | 209 |
Win rate | 56.46 |
Use rpsrunner.py to play unranked matches on your computer.
import random
beats = {'R':'P', 'P':'S', 'S':'R'}
if not input:
history = 'RPS'
win_over_losses = 0
history += input
if input:
win_over_losses += output == beats[input]
win_over_losses -= input == beats[output]
output = beats[random.choice(history)]
# Sore winner
if win_over_losses >= 30:
output = random.choice('RPS')