Random CopyCat

AuthorAhri Fox
Submission date2018-01-02 09:23:31.733880
Rating3118
Matches played310
Win rate32.58

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

Source code:

import random

rps = ["R", "P", "S"]

lastOutput="R"

if input == "":
    lastOutput = random.choice(rps)
    output=lastOutput
else:
    if input == lastOutput:
        lastOutput = random.choice(rps)
        output = lastOutput
    else:
        if random.randint(0,4)<2:
            lastOutput=input
            output=input
        elif random.randint(0,1)==0:
            rpsTmp = ["R", "P", "S"]
            rpsTmp.remove(input)
            rpsTmp.remove(lastOutput)
            lastOutput = random.choice(rpsTmp)
            output = lastOutput
        else:
            lastOutput = random.choice(rps)
            output = lastOutput