Author | xyz |
Submission date | 2019-06-08 22:06:00.710838 |
Rating | 1660 |
Matches played | 234 |
Win rate | 20.09 |
Use rpsrunner.py to play unranked matches on your computer.
import random
if input == "":
a = ""
b = ""
else:
a = b
b = input
if a == b: # If the inputs are equal, assume the human will change.
if b == "R": # Human will change to either scissors or paper.
output = "S"
elif b == "S": # Human will change to either rock or paper.
output = "P"
elif b == "P": # Human will change to either rock or scissors.
output = "R"
elif b == "": # This is the first turn, make a random choice.
output = random.choice(["R", "S", "P"])
else:
if input == "R":
output = "S"
elif input == "P":
output = "R"
elif input == "S":
output = "P"
else:
output = random.choice(["R","P","S"])