Author | iggi |
Submission date | 2019-02-04 20:01:50.410320 |
Rating | 3930 |
Matches played | 251 |
Win rate | 35.46 |
Use rpsrunner.py to play unranked matches on your computer.
import random
if not input:
moves = ["R", "P", "S"] # possible outputs
beatenBy = {"R": "P", "P": "S", "S": "R"} # list of outcomes with string index
lPlayed = random.choice(moves) #first play is random
output = lPlayed
else:
lReceived = input
if lReceived == beatenBy.get(lPlayed, None):
lPlayed = beatenBy.get(lReceived, None) # if previous play lost switch to the play that would win the previous play
output = lPlayed