Author | csd |
Submission date | 2019-06-06 06:07:27.096457 |
Rating | 4329 |
Matches played | 238 |
Win rate | 46.64 |
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 > paperCount and rockCount > scissorsCount:
# rock is most common
if paperCount > scissorsCount:
choices = "PPPSSR"
else:
choices = "PPPRRS"
elif paperCount > scissorsCount:
# paper is most common
if rockCount > scissorsCount:
choices = "SSSPPR"
else:
choices = "SSSRRP"
else:
# scissors is most common
if rockCount > paperCount:
choices = "RRRPPS"
else:
choices = "RRRSSP"
output = random.choice(choices)