JLAP

AuthorDuMa
Submission date2019-02-11 08:47:52.079611
Rating4328
Matches played250
Win rate41.2

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

Source code:

import random
global PSpinner
global NSpinner
global spinner
global single
global out
global opMoves
global firstTen
global rounds
global LAP
winP = {"R":"P","S":"R","P":"S"}
if input == "":
    firstTen = ["R","P","R","S","P","R","P","R","S","P"]
    rounds = 0
    single = False
    spinner = False
    PSpinner = False
    NSpinner = False
    LAP = True
    opMoves = []
    out = "R"
elif rounds < 10:
    opMoves.append(input)
    out = firstTen[rounds]
elif PSpinner:
    opMoves.append(input)
    out = opMoves[opMoves.__len__()-2]
elif NSpinner:
    opMoves.append(input)
    out = input
elif single:
    opMoves.append(input)
    out = winP[input]
elif input == opMoves[opMoves.__len__()-1]:
    opMoves.append(input)
    same = True
    for x in (0,8):
        if not (input == opMoves[opMoves.__len__()-x-1]):
            same = False
    if same:
        single = True
elif LAP:
    R = False
    P = False
    S = False
    i = 0
    while (not R or not P or not S) and not i>opMoves.__len__()-1:
        i+=1
        if opMoves[opMoves.__len__()-i] == "R" and not R:
            if (P and S) or i>opMoves.__len__():
                out = "P"
            R = True
        elif opMoves[opMoves.__len__()-i] == "P" and not P:
            if (R and S) or i > opMoves.__len__():
                out = "S"
            P = True
        elif opMoves[opMoves.__len__()-i] == "S" and not S:
            if (R and S) or i > opMoves.__len__():
                out = "R"
            S = True
        else:
            out = random.choice(["R","P","S"])
elif input == opMoves[opMoves.__len__()-6]:
    opMoves.append(input)
    same = True
    for x in (0,5):
        if not (opMoves[opMoves.__len__()-x-2] == opMoves[opMoves.__len__()-x-5]):
            same = False
    if same:
        spinner = True
    if spinner:
        if winP[input]==opMoves[opMoves.__len__()-2]:
            NSpinner = True
            out = input
        else:
            PSpinner = True
            out = opMoves[opMoves.__len__() - 2]
    else:
        LAP = True
else:
    out = random.choice(["R", "P", "S"])
output = out
rounds+=1