Final5

AuthorChristina Oyebade
Submission date2017-12-14 18:26:17.355170
Rating5207
Matches played312
Win rate48.72

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

Source code:

import random 
countRock = 0
countPaper = 0
countScissors = 0
str = []  
input = [] #This is the user's input as string

##########Checks the User's overall preference of r, p or s 

if input == []: # initialize variables for the first round
	countRock = countPaper = countScissors = 0
elif input == ["R"]:
	countRock += 1 
        str.append("R")
elif input == ["P"]:
	countPaper += 1 
        str.append("P")
elif input == ["S"]:
	countScissors += 1  
        str.append("S")



##############################################################################


if str[-3:] == ["R","R","R"] and countRock > countPaper and countRock > countScissors:
    output = "P" 
elif str[-3:] == ["P","P","P"] and countPaper > countRock and countPaper>countScissors:
    output = "S"
elif str[-3:] == ["S","S","S"] and countScissors > countPaper and countPaper > countRock:
    output = "R"
elif str[-3:] == ["S","S","P"] and countScissors> countRock and countScissors >countPaper: #if they've favored scissors
    output = "R" #rock beats scissors 
elif str[-3:] == ["R","R","S"] and countRock > countPaper and countRock > countScissors:
    output = "P"
elif str[-3:] == ["P","P","R"] and countPaper > countRock and countPaper>countScissors:
    output = "S"
elif str[-3:] == ["P","P","S"] and countPaper > countRock and countPaper>countScissors:
    output = random.choice(["R","P","S"])
elif len(str[-2:]) < 2:
    output = random.choice(["R","P","S"])
elif str[-2:] == ["R","R"]:
    output = "P"
elif str[-2:] == ["P","P"]:
    output = "S"
elif str[-2:] == ["S","S"]:
    output = "R"
else:
    if countRock > countPaper and countRock > countScissors:
	output = "P" # paper beats rock
    elif countPaper > countScissors:
	output = "S" # scissors beats paper
    else:
	output = random.choice(["R", "P", "S"])