psychology

Authorleowu2017
Submission date2017-12-05 18:45:25.516860
Rating3956
Matches played319
Win rate40.75

Use rpsrunner.py to play unranked matches on your computer.

Source code:

# 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')