Author | RANDOM_=D |
Submission date | 2011-05-21 21:48:56.695515 |
Rating | 4242 |
Matches played | 7391 |
Win rate | 48.25 |
Use rpsrunner.py to play unranked matches on your computer.
import random
r = random.randrange(0,1)
if r==0:
move = random.randrange(0,3)
if move == 1:
output = "R"
elif move == 2:
output = "P"
else:
output = "S"
elif r==1:
if input=="": # initialize variables for the first round
rockCount = paperCount = scissorsCount = 0
if input == "R":
rockCount += 1
elif input == "P":
paperCount += 1
elif input == "S":
scissorsCount += 1
if rockCount > paperCount and rockCount > scissorsCount:
output = "P" # paper beats rock
elif paperCount > scissorsCount:
output = "S" # scissors beats paper
else:
output = "R" # rock beats scissors