Author | austin! |
Submission date | 2018-03-07 21:45:01.741340 |
Rating | 5538 |
Matches played | 299 |
Win rate | 56.19 |
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" and last3 == "R":
output = "P"
elif last == "P" and last2 == "P" and last3 == "P":
output = "S"
elif last == "S" and last2 == "S" and last3 == "S":
output = "R"
else:
output = random.choice(["P","S","R"]) # rock beats scissors