Author | dirknbr |
Submission date | 2019-03-16 14:39:40.300481 |
Rating | 4766 |
Matches played | 258 |
Win rate | 43.8 |
Use rpsrunner.py to play unranked matches on your computer.
# keep track
# http://www.rpscontest.com/authorSearch?name=dirknbr
import random
rps = ['R', 'P', 'S']
best = {'R': 'P', 'P': 'S', 'S': 'R'}
hist_me = []
hist_opp = []
def freq(x):
# find most frequent
ff = [(x.count(i), i) for i in rps]
ff = sorted(ff, reverse=True)
return ff[0][1]
if input == '':
output = random.choice(rps)
else:
hist_opp.append(input)
ff = freq(hist_opp)
# print(ff)
output = best[ff]
hist_me.append(output)