Granite Launcher

This program has been disqualified.


AuthorEbTech
Submission date2011-06-21 19:43:40.519042
Rating7963
Matches played2453
Win rate79.17

Source code:

# throws rocks!

import random

if not input:
	beat = {'R':'P','P':'S','S':'R'}
	fusion = {'RP':'a','PS':'b','SR':'c','PR':'d','SP':'e','RS':'f','RR':'g','PP':'h','SS':'i'}
	limits = [4, 10, 25, 60]
	moves = ["","",""]
	number_of_predictors = 6*len(limits)*len(moves)
	predictors = range(number_of_predictors)
	predictorscore = range(number_of_predictors)
	for i in range(number_of_predictors):
		predictors[i] = random.choice(['R','P','S'])
		predictorscore[i] = random.random()*0.1;
	threat = [0,0,0]
	outcome = 0
	length = 0
	output = random.choice(['R','P','S'])
else:
	oldoutcome = outcome
	if (beat[input] == output):
		outcome = 1
	elif (input == beat[output]):
		outcome = -1
	else:
		outcome = 0
	threat[oldoutcome + 1] *= 0.96
	threat[oldoutcome + 1] -= outcome
	for i in range(number_of_predictors):
		predictorscore[i] *= 0.8
		predictorscore[i] += (beat[input] == predictors[i])
		predictorscore[i] -= (input == beat[predictors[i]])
	moves[0] += input
	moves[1] += output
	moves[2] += fusion[input+output]
	length += 1
	
	for z in range(3*len(limits)):
		j = min([length-1, limits[z//3]])
		while not moves[z%3][length-j:length] in moves[z%3][0:length-1]:
			j-=1
		i = moves[z%3].rfind(moves[z%3][length-j:length], 0, length-1)
		predictors[2 * z] = moves[0][j+i]
		predictors[2*z+1] = moves[1][j+i]
	for i in range(number_of_predictors/3, number_of_predictors):
		predictors[i] = beat[predictors[i - number_of_predictors/3]]
	
	if random.random() < 0.2*threat[outcome+1]+0.1:
		output = random.choice(['R','P','S'])
	else:
		output = predictors[predictorscore.index(max(predictorscore))]