Author | nk! |
Submission date | 2017-12-06 16:55:45.456910 |
Rating | 4836 |
Matches played | 324 |
Win rate | 44.75 |
Use rpsrunner.py to play unranked matches on your computer.
import random
opponentMoves=[]
if input == "":
opponentMoves = []
elif input == "R":
opponentMoves += "R"
elif input == "P":
opponentMoves += "P"
elif input == "S":
opponentMoves += "S"
def analyzeList(opponentMoves, L):
L = opponentMoves[:-4]
if L == "":
output = random.choice(["R","P","S"])
elif L in opponentMoves[0:4]:
if L[0]== "R":
output= "P"
elif L[0]== "P":
output= "S"
elif L[0]== "S":
output= "R"
elif L not in opponentMoves[4:]:
return analyzeList(opponentMoves[1:], L[1:])
if len(opponentMoves)<=9:
output=random.choice(["R","P","S"])
else:
analyzeList(opponentMoves, L)