Author | xsasxax |
Submission date | 2019-06-07 17:23:12.140829 |
Rating | 4724 |
Matches played | 229 |
Win rate | 45.41 |
Use rpsrunner.py to play unranked matches on your computer.
import re
import random
if input == "":
opponentbotmoves = ""
else:
opponentbotmoves += input
opponentbotmoves = opponentbotmoves[-4:] #cosidering last 4 moves of the opponent
likely = {'R': 0, 'P': 0, 'S': 0}
for i in range(1, len(opponentbotmoves) - 1):
pattern = opponentbotmoves[-i:] + "."
for match in re.findall(pattern, opponentbotmoves):
likely[match[-1]] += 1
opponentbotprediction = max(likely, key=lambda m: likely[m])
if opponentbotprediction == 'R':
output = 'P'
elif opponentbotprediction == 'P':
output = 'S'
elif opponentbotprediction == 'S':
output = 'R'