mvsS2

AuthorMarco
Submission date2019-02-05 20:47:55.790080
Rating2458
Matches played248
Win rate22.18

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

Source code:

import random
class RPS:
    previousOut = "R"
    previousWin = "R"

def calculateWin(x,y):
    if x == y:
        return "D"

    if x == "R" and y == "S" :
        return "L"
    if x == "S" and y == "P" :
        return "L"
    if x == "P" and y == "R" :
        return "L"

    if y == "R" and x == "S" :
        return "W"
    if y == "S" and x == "P" :
        return "W"
    if y == "P" and x == "R" :
        return "W"


if input == "" :
    RPS.previousOut = random.choice(["R","P","S"])
    output = RPS.previousOut

else:
    RPS.previousWin = calculateWin(input, RPS.previousOut)
    if RPS.previousWin == "L":
        if input == "R":
            RPS.previousOut = "P"
            output = RPS.previousOut

        elif input == "P":
            RPS.previousOut = "S"
            output = RPS.previousOut

        elif input == "S":
            RPS.previousOut = "R"
            output = RPS.previousOut

    if RPS.previousWin == "W":
        RPS.previousOut = input
        output = RPS.previousOut

    if RPS.previousWin == "D":
        if input == "R":
            RPS.previousOut = "S"
            output = RPS.previousOut

        elif input == "P":
            RPS.previousOut = "R"
            output = RPS.previousOut

        elif input == "S":
            RPS.previousOut = "P"
            output = RPS.previousOut