Author | hawk |
Submission date | 2011-06-09 09:08:41.121450 |
Rating | 5962 |
Matches played | 5454 |
Win rate | 57.76 |
Use rpsrunner.py to play unranked matches on your computer.
import random
if input == "":
rc, pc, sc = 0, 0, 0
elif input == "R":
rc += 1
elif input == "P":
pc += 1
elif input == "S":
sc += 1
tc = rc + pc + sc
if tc < 100:
output = random.choice(["R", "P", "S"])
else:
r = random.randint(1, tc)
if r <= rc:
output = "P"
elif r <= rc + pc:
output = "S"
else:
output = "R"