Author | Henry Elliott |
Submission date | 2017-07-28 05:13:03.589710 |
Rating | 4144 |
Matches played | 339 |
Win rate | 41.0 |
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 = "R"
elif selection >= rock_count + 1 and selection <= rock_count + paper_count:
output = "P"
else:
output = "S"