Author | Jacob |
Submission date | 2020-02-01 18:31:59.280925 |
Rating | 6509 |
Matches played | 203 |
Win rate | 66.01 |
Use rpsrunner.py to play unranked matches on your computer.
import random
if input == "":
opponentMoves = []
else:
opponentMoves.append(input)
length = len(opponentMoves)
endingSize = min(length - 1, 6)
output = None
counters = {'R': 'P', 'P': 'S', 'S': 'R'}
for k in range(endingSize):
endOfList = opponentMoves[length - endingSize + k:]
for i in range(0, length - 1 - endingSize):
for j in range(endingSize, 0, -1):
if opponentMoves[i:i + j] == endOfList:
output = counters[opponentMoves[i + j]]
break
else:
continue
break
else:
continue
break
if output is None:
output = random.choice(["R", "P", "S"])