Author | Naturel |
Submission date | 2014-01-16 23:16:20.126823 |
Rating | 3471 |
Matches played | 625 |
Win rate | 35.84 |
Use rpsrunner.py to play unranked matches on your computer.
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