Author | jiaw |
Submission date | 2011-09-10 03:52:21.831375 |
Rating | 3392 |
Matches played | 2599 |
Win rate | 28.05 |
Use rpsrunner.py to play unranked matches on your computer.
import random
#test = random.choice(["R","P","S"])
#output = test
#total = 1000
#counter = 0
#bucket = []
#RC = PC = SC = 0
if input == "": # initialize variables for the first round
RC = PC = SC = 0
counter = 0
elif input == "R":
RC+= 1
counter += 1
elif input == "P":
PC += 1
counter += 1
elif input == "S":
SC += 1
counter += 1
if counter <= 10:
test = random.choice(["R","P","S"])
output = test
else:
if RC > PC and RC > SC:
output = "P" # paper beats rock
RC = RC/2
elif PC > SC and PC > RC:
output = "S" # scissors beats paper
PC = PC/2
else:
output = "R" # rock beats scissors
RC = RC/2