Author | rhiz |
Submission date | 2011-06-22 05:40:05.652392 |
Rating | 2379 |
Matches played | 4979 |
Win rate | 22.98 |
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 rockCount == 0 or paperCount == 0 or scissorsCount == 0:
output = random.choice(["R","P","S"])
elif rockCount % 4 == 0:
rockCount += 1
output = "R"
elif paperCount % 4 == 0:
paperCount += 1
output = "P"
elif scissorsCount % 4 == 0:
scissorsCount += 1
output = "S"
elif rockCount > paperCount and rockCount > scissorsCount:
output = random.choice(["R","S"])
elif paperCount > scissorsCount:
output = random.choice(["R","P"])
else:
output = random.choice(["P","S"])