Author | leowu2017 |
Submission date | 2017-12-05 18:45:25.516860 |
Rating | 3956 |
Matches played | 319 |
Win rate | 40.75 |
Use rpsrunner.py to play unranked matches on your computer.
# reference: https://www.youtube.com/watch?v=rudzYPHuewc
# https://arxiv.org/pdf/1404.5199v1.pdf
import random
if not input:
output = random.choice('RPS')
beat = {'R':'P', 'P':'S', 'S':'R'}
else:
if (output == 'R' and input == beat['R']) or (output == 'P' and input == beat['P']) or (output == 'S' and input == beat['S']): # opponent win
output = beat[input]
elif (input == 'R' and output == beat['R']) or (input == 'P' and output == beat['P']) or (input == 'S' and output == beat['S']): # opponent loss
output = input
else:
output = random.choice('RPS')