Author | TidyMaze |
Submission date | 2018-08-26 20:10:42.064123 |
Rating | 3651 |
Matches played | 272 |
Win rate | 34.19 |
Use rpsrunner.py to play unranked matches on your computer.
import random
def beating(symb):
return {
"R": "P",
"P": "S",
"S": "R"
}.get(symb)
if input == "": # initialize variables for the first round
countOpp = {
"R": 0,
"P": 0,
"S": 0
}
countMe = {
"R": 0,
"P": 0,
"S": 0
}
else:
countOpp[input] += 1
if input == "":
output = random.choice(["R","P","S"])
else:
sortedItems = sorted(countMe.items(), key=lambda x:-x[1])
allBests = list(filter(lambda x: x[1] == sortedItems[0][1], sortedItems))
best = random.choice(allBests)[0]
output = beating(beating(best))
countMe[output] += 1