bestAgainDefault

AuthorTidyMaze
Submission date2018-08-26 16:10:18.192369
Rating2458
Matches played268
Win rate22.01

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

Source code:

import random

def beating(symb):
    return {
        "R": "P",
        "P": "S",
        "S": "R"
    }.get(symb)

countOpp = {
    "R": 0,
    "P": 0,
    "S": 0
}

countMe = {
    "R": 0,
    "P": 0,
    "S": 0
}

if input == "": # initialize variables for the first round
	pass
else:
    countOpp[input] += 1

if input == "":
    output = random.choice(["R","P","S"])
else:
    sortedItems = sorted(countMe.items(), key=lambda x:-x[1])
    output = sortedItems[0][0]

countMe[output] += 1