Author | gilfish |
Submission date | 2019-03-14 00:16:30.717485 |
Rating | 4229 |
Matches played | 249 |
Win rate | 44.18 |
Use rpsrunner.py to play unranked matches on your computer.
# Forget opponent's past moves at the rate lambda.
# This anticipates a change in the opponent's strategy.
alpha = 0.7
if input == "": # initialize variables for the first round
rockCount = paperCount = scissorsCount = 0
elif input == "R":
rockCount += 1
elif input == "P":
paperCount += 1
elif input == "S":
scissorsCount += 1
rockCount *= alpha
paperCount *= alpha
scissorsCount *= alpha
if rockCount > paperCount and rockCount > scissorsCount:
output = "P" # paper beats rock
elif paperCount > scissorsCount:
output = "S" # scissors beats paper
else:
output = "R" # rock beats scissors