| Author | frodewin | 
| Submission date | 2018-09-18 10:00:21.701535 | 
| Rating | 4073 | 
| Matches played | 265 | 
| Win rate | 40.0 | 
Use rpsrunner.py to play unranked matches on your computer.
import random
HISTORY_L=10
def most_common(l):
    max = 0
    maxitem = None
    for x in set(l):
        count =  l.count(x)
        if count > max:
            max = count
            maxitem = x
    return maxitem
if input == "": # initialize variables for the first round
    RPS=["R","P","S"]
    history=''
    offset=0
    for n in range(1, HISTORY_L):
            history += random.choice(['R','P','S'])
    lastgames=[]
    scoring = {
    "R": {
        "R": 0,
        "P": -1,
        "S": 1
    },
    "P": {
        "R": 1,
        "P": 0,
        "S": -1
    },
    "S": {
        "R": -1,
        "P": 1,
        "S": 0
    }
    }
else:
    history += input
    lastgames.append(scoring[output][input])
    hlen=random.randint(2,5)
    if (sum(lastgames[-hlen:]) < -1):
        offset+=2
guess=most_common(history[-HISTORY_L:-1])
if guess == "R":
	select = 1
elif guess == "P":
	select = 2
else:
	select = 0
output=RPS[(select+offset) % 3]