Author | Jacob |
Submission date | 2020-02-01 02:23:47.729155 |
Rating | 3308 |
Matches played | 201 |
Win rate | 31.84 |
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, 5)
output = None
for k in range(0, 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 = opponentMoves[i + j]
break
else:
continue
break
else:
continue
break
if output == None:
output = random.choice(["R", "P", "S"])