Mosterd2

AuthorNaturel
Submission date2014-01-09 00:22:02.126488
Rating2520
Matches played649
Win rate22.19

Use rpsrunner.py to play unranked matches on your computer.

Source code:

if input == "":
    import re
    opponentMoves = ""
else:
    opponentMoves += input

opponentMoves = "rpsrpsrps".upper()
opponentMoves = "rpsrpsrps".upper()

likely = {'R': 0, 'P': 0, 'S': 0}
for i in range(1, len(opponentMoves) - 1):
    pattern = opponentMoves[-i:] + "."
    for match in re.findall(pattern, opponentMoves):
        likely[match[-1]] += 1

opponent_prediction = max(likely, key=lambda m: likely[m])

if opponent_prediction == 'R':
    output = 'P'
elif opponent_prediction == 'P':
    output = 'S'
elif opponent_prediction == 'S':
    output = 'R'