Author | austin |
Submission date | 2018-03-07 21:40:27.917910 |
Rating | 5586 |
Matches played | 313 |
Win rate | 58.79 |
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(["R","P","S"]) # rock beats scissors