Author | Sean |
Submission date | 2016-02-10 16:31:07.338030 |
Rating | 6096 |
Matches played | 412 |
Win rate | 58.74 |
Use rpsrunner.py to play unranked matches on your computer.
import random
if input == "":
beat = {"R": "P", "P": "S", "S": "R"}
counts = {"R": 1, "P": 1, "S": 1}
else:
counts[input] += 2
t = sum(counts.values())
r = random.randint(0, t)
p = 0
for s, n in counts.iteritems():
p += n
if r <= p:
break
output = beat[s]