Author | Emmanuel Harish Menon |
Submission date | 2019-06-03 11:25:42.991846 |
Rating | 4968 |
Matches played | 234 |
Win rate | 47.86 |
Use rpsrunner.py to play unranked matches on your computer.
import random
import operator
pickCounter = {"R": 0, "P": 0, "S": 0}
winningMoves = {"R": "P", "P": "S", "S": "R"}
def getDictMax(dictionary):
return max(dictionary.items(), key=operator.itemgetter(1))[0]
if input is "":
output = random.choice(["R", "P", "S"])
else:
pickCounter[input] += 1
output = winningMoves[getDictMax(pickCounter)]