| Author | nk! | 
| Submission date | 2017-12-14 03:56:53.156080 | 
| Rating | 5635 | 
| Matches played | 288 | 
| Win rate | 52.08 | 
Use rpsrunner.py to play unranked matches on your computer.
import random
opponentMoves = str(["R","S","R","S","P","R","S","P","R","S","P","S","R","S","P","R","S","S","R","S","P","R","S","S","S","R","S","S","S","R","S"])
last4 = opponentMoves[-4:]
if input == "":
    opponentMoves = ""
elif input == "R":
    opponentMoves += "R"
elif input == "P":
    opponentMoves += "P"
elif input == "S":
    opponentMoves += "S"
def count_substring(opponentMoves, last4):
    count = 0
    for i in range(len(opponentMoves)):
        count += opponentMoves[i]==last4
    return count
"""
    if len(opponentMoves)==0:
        return 0
    if opponentMoves[0:4]==last4:
        return 1 + count_substring(opponentMoves[1:])
    else: 
        return 0 + count_substring(opponentMoves[1:])
"""
countR = count_substring(opponentMoves, last4 + "R")
countP = count_substring(opponentMoves, last4 + "P")
countS = count_substring(opponentMoves, last4 + "S")
if countR>countP>countS:
    output = "P"
elif countP>countR>countS:
    output = "S"
elif countS>countP>countR:
    output = "R"
elif countS == countP == countR:
    output = random.choice(["R","P","S"])