LeastExpected

AuthorNaturel
Submission date2014-01-16 23:16:20.126823
Rating3471
Matches played625
Win rate35.84

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

Source code:

import random
winner = {"R": "P", "P": "S", "S": "R"}

if not input:
    mypattern = {}
    mypattern["R"] = {"R": 0, "P": 0, "S": 0}
    mypattern["P"] = {"R": 0, "P": 0, "S": 0}
    mypattern["S"] = {"R": 0, "P": 0, "S": 0}
    last = random.choice("RPS")
    output = random.choice("RPS")
else:
    now = mypattern[last]
    output = min(now, key=lambda m: now[m])

mypattern[last][output] += 1
last = output