Test_00004

AuthorJacob
Submission date2020-02-01 18:31:59.280925
Rating6509
Matches played203
Win rate66.01

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

Source code:

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"])