GG3

AuthorGary
Submission date2019-02-04 17:44:27.157153
Rating4722
Matches played254
Win rate44.49

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

Source code:

import random
R = 0;
P = 0;
S = 0;
str = []
if input == "": # initialize variables for the first round
	R = P = S = 0
elif input == "R":
    R += 1
    str.append("R")
elif input == "P":
    P += 1
    str.append("P")
elif input == "S":
    S += 1
    str.append("S")
temp=""
if(len(str)>=9):
    temp = str.pop(0)

elif temp == "R":
    R -= 1
elif temp == "P":
    P -= 1
elif temp == "S":
    S -= 1

if R > P and R > S:
    if temp != "P":
	    output = "P" # paper beats rock
    else:
        output = random.choice(["R","S"])
elif P > S:
    if temp != "S":
        output = "S" # scissors beats paper
    else:
        output = random.choice(["R","P"])
else:
    if temp != "R":
	    output = "R" # rock beats scissors
    else:
        output = random.choice(["P","S"])