Author | Richard |
Submission date | 2012-10-20 20:01:54.746131 |
Rating | 5418 |
Matches played | 770 |
Win rate | 52.08 |
Use rpsrunner.py to play unranked matches on your computer.
import random
if input == "": # initialize variables for the first round
rockCount = paperCount = scissorsCount = 0
elif input == "R":
rockCount += 1
elif input == "P":
paperCount += 1
elif input == "S":
scissorsCount += 1
if random.random() < 0.015:
if rockCount==paperCount==scissorsCount:
output = random.choice(["R","P","S"])
elif rockCount > paperCount and rockCount > scissorsCount:
output = "P" # paper beats rock
elif paperCount > scissorsCount:
output = "S" # scissors beats paper
else:
output = "R" # rock beats scissors
rockCount = paperCount = scissorsCount = 0
else:
output = random.choice(["R","P","S"])