Author | dhmtr |
Submission date | 2017-12-31 16:46:56.777550 |
Rating | 5225 |
Matches played | 332 |
Win rate | 46.99 |
Use rpsrunner.py to play unranked matches on your computer.
import random
pmc = "R"
def v(x, y):
if x=="R" and y=="S" or x=="P" and y=="R" or x=="S" and y=="P":
return 1
else:
return 0
def s(x):
if x=="R":
return "P"
elif x=="P":
return "S"
else:
return "R"
if input == "": # initialize variables for the first round
output = random.choice(["R","P","S"])
pmc = output
else:
if v(pmc, input)==1:
#if you win
output = pmc
else:
#if you lose
output = s(input)
pmc = output