Author | secret |
Submission date | 2015-02-09 14:44:23.767903 |
Rating | 5617 |
Matches played | 533 |
Win rate | 58.35 |
Use rpsrunner.py to play unranked matches on your computer.
import random
import math
if input == "": # initialize variables for the first round
r=p=s= 0
elif input == "R":
r+= 1
elif input == "P":
p+= 1
elif input == "S":
s+= 1
rv=int((r+1)**0.5)
pv=int((p+1)**0.5)
sv=int((s+1)**0.5)
ra=random.randrange(rv+pv+sv)
if ra<rv:
output = "P" # paper beats rock
elif ra < rv+pv:
output = "S" # scissors beats paper
else:
output = "R" # rock beats scissors