derp_v1

Authorevolvingstuff
Submission date2011-06-10 03:44:36.148727
Rating7182
Matches played5176
Win rate72.35

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

Source code:

import random
if input == "":
    padding = 7.0
    decay_model = 0.75
    history = []
    my_prev = ''
    first_order = {}
    for i in ['R','P','S']:
        for j in ['R','P','S']:
            for k in ['R','P','S']:
                first_order[i+j+k] = padding
else:
    your_prev = input
    history.append((my_prev, your_prev))
if len(history) >= 2:
    pred = [1,1,1]
    pred[0] = first_order[my_prev + your_prev + 'R']
    pred[1] = first_order[my_prev + your_prev + 'P']
    pred[2] = first_order[my_prev + your_prev + 'S']
    first_order[history[-2][0] + history[-2][1] + history[-1][1]] += 1
    first_order[my_prev + your_prev + 'R'] *= decay_model
    first_order[my_prev + your_prev + 'P'] *= decay_model
    first_order[my_prev + your_prev + 'S'] *= decay_model
    
    if random.random() < pred[0] / sum(pred):
        output = "P"
    elif random.random() < pred[1] / sum(pred[1:]):
        output = "S"
    else:
        output = "R"
else:
    output = random.choice(['R','P','S'])
my_prev = output