Golden Banana

This program has been disqualified.


AuthorEbTech
Submission date2011-05-25 19:34:24.884970
Rating6335
Matches played4524
Win rate62.91

Source code:

import math
import random

if not input:
    hist = [[[[[1/3,1/3],[1/3,1/3],[1/3,1/3],[1/3,1/3],[1/3,1/3],[1/3,1/3],[1/3,1/3],[1/3,1/3],[1/3,1/3]] for i in range(9)] for j in range(9)] for k in range(9)]
    prev = [0,0,0,0]
    olast = 0
    ilast = 0
else:
    ilast = {'R':0, 'P':1, 'S':2}[input]
    
    hist[prev[3]][prev[0]][prev[1]][prev[2]][0] *= 0.7
    hist[prev[3]][prev[0]][prev[1]][prev[2]][1] *= 0.7
    if ilast < 2:
        hist[prev[3]][prev[0]][prev[1]][prev[2]][ilast] += 0.45
    for i in range(0,8):
        hist[prev[3]][i][prev[1]][prev[2]][0] *= 0.88
        hist[prev[3]][i][prev[1]][prev[2]][1] *= 0.88
        if ilast < 2:
            hist[prev[3]][i][prev[1]][prev[2]][ilast] += 0.2
        for j in range(0,8):
            hist[prev[3]][i][j][prev[2]][0] *= 0.95
            hist[prev[3]][i][j][prev[2]][1] *= 0.95
            if ilast < 2:
                hist[prev[3]][i][j][prev[2]][ilast] += 0.08
            for k in range(0,8):
                hist[prev[3]][i][j][k][0] *= 0.98
                hist[prev[3]][i][j][k][1] *= 0.98
                if ilast < 2:
                    hist[prev[3]][i][j][k][ilast] += 0.03
    prev[0] = prev[1]
    prev[1] = prev[2]
    prev[2] = prev[3]
    prev[3] = 3*olast+ ilast

prob = hist[prev[3]][prev[0]][prev[1]][prev[2]]
rateR = math.exp(5*(1-prob[0]-2*prob[1]))
rateP = math.exp(5*(2*prob[0]+prob[1]-1))
rateS = math.exp(5*(prob[1]-prob[0]))
randNum = random.random()*(rateR+rateP+rateS)

if randNum < rateR:
    output = "R"
elif randNum < rateR+rateP:
    output = "P"
else:
    output = "S"
olast = {'R':0, 'P':1, 'S':2}[output]