Author | joseph |
Submission date | 2018-03-08 19:59:35.606320 |
Rating | 4112 |
Matches played | 316 |
Win rate | 43.99 |
Use rpsrunner.py to play unranked matches on your computer.
import random
if input == "": # initialize variables for the first round
last = " "
last2 = " "
last3 = " "
elif input == "R":
last3 = last2
last2 = last
last = "R"
elif input == "P":
last3 = last2
last2 = last
last = "P"
elif input == "S":
last3 = last2
last2 = last
last = "S"
if last == "R" and last2 == "R":
output = "P"
elif last == "P" and last2 == "P":
output = "S"
elif last == "S" and last2 == "S":
output = "R"
else:
output = random.choice(["R","P","S"]) # rock beats scissors