dirk2

Authordirknbr
Submission date2019-03-16 14:39:40.300481
Rating4766
Matches played258
Win rate43.8

Use rpsrunner.py to play unranked matches on your computer.

Source code:

# 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)