Golden Banana

This program has been disqualified.


AuthorEbTech
Submission date2011-05-25 19:56:20.391818
Rating6093
Matches played2737
Win rate66.57

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.55
    hist[prev[3]][prev[0]][prev[1]][prev[2]][1] *= 0.55
    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.8
        hist[prev[3]][i][prev[1]][prev[2]][1] *= 0.8
        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.92
            hist[prev[3]][i][j][prev[2]][1] *= 0.92
            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.97
                hist[prev[3]][i][j][k][1] *= 0.97
                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]