Author | Henry Elliott |
Submission date | 2017-07-28 05:18:56.090070 |
Rating | 6058 |
Matches played | 351 |
Win rate | 56.7 |
Use rpsrunner.py to play unranked matches on your computer.
import random
if input == "":
sys_rand = random.SystemRandom()
rock_count = paper_count = scissor_count = 0
elif input == "R":
rock_count += 1
elif input == "P":
paper_count += 1
elif input == "S":
scissor_count += 1
if input == "":
output = sys_rand.choice(["R", "P", "S"])
else:
selection = sys_rand.randint(1, rock_count + paper_count + scissor_count)
if selection >= 1 and selection <= rock_count:
output = "P"
elif selection >= rock_count + 1 and selection <= rock_count + paper_count:
output = "S"
else:
output = "R"