Author | pyfex |
Submission date | 2011-06-12 08:07:54.155737 |
Rating | 5490 |
Matches played | 5224 |
Win rate | 55.86 |
Use rpsrunner.py to play unranked matches on your computer.
import random
if input == "":
counter = {'P': 'S', 'R': 'P', 'S':'R'}
score = {'RR': 0, 'PP': 0, 'SS': 0, 'PR': 1, 'RS': 1, 'SP': 1,'RP': -1, 'SR': -1, 'PS': -1,}
opp_played = []
me_played = []
output = random.choice(['R', 'P', 'S'])
candidates = [output, output]
performance = [0, 0]
else:
opp_played.append(input)
me_played.append(input)
performance[0] += score[candidates[0]+input]
performance[1] += score[candidates[1]+input]
idx = performance.index(max(performance))
candidates[0] = counter[random.choice(opp_played)]
candidates[1] = counter[counter[random.choice(me_played)]]
output = candidates[idx]