Omelet from Mercury

This program has been disqualified.


AuthorEbTech
Submission date2011-06-21 01:13:15.670782
Rating7755
Matches played2142
Win rate78.1

Source code:

#descendant or ancestor of a long lineage of Earthling bots (concluding with DNA Werfer 8)?

import random

if not input:
	number_of_predictors = 54
	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
	beat = {'R':'P','P':'S','S':'R'}
	nuclease = {'RP':'a','PS':'b','SR':'c','PR':'d','SP':'e','RS':'f','RR':'g','PP':'h','SS':'i'}
	limits = [50,17,6]
	length = 0
	urmoves = ""
	mymoves = ""
	DNAmoves = ""
	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] == oldpredictors[i])
		predictorscore[i] -= (input == beat[oldpredictors[i]])
	#History matching
	urmoves += input
	mymoves += output
	DNAmoves += nuclease[input+output]
	length += 1
	
	for z in range(3):
		limit = min([length-1, limits[z]])
		j = limit
		while j>=1 and not DNAmoves[length-j:length] in DNAmoves[0:length-1]:
			j-=1
		if j>=1:
			i = DNAmoves.rfind(DNAmoves[length-j:length], 0, length-1)
			predictors[0+6*z] = urmoves[j+i]
			predictors[1+6*z] = mymoves[j+i]
		j = limit
		while j>=1 and not urmoves[length-j:length] in urmoves[0:length-1]:
			j-=1
		if j>=1:
			i = urmoves.rfind(urmoves[length-j:length], 0, length-1) 
			predictors[2+6*z] = urmoves[j+i]
			predictors[3+6*z] = mymoves[j+i]
		j = limit
		while j>=1 and not mymoves[length-j:length] in mymoves[0:length-1]:
			j-=1
		if j>=1:
			i = mymoves.rfind(mymoves[length-j:length], 0, length-1) 
			predictors[4+6*z] = urmoves[j+i]
			predictors[5+6*z] = mymoves[j+i]
	for i in range(number_of_predictors/3, number_of_predictors):
		predictors[i] = beat[predictors[i - number_of_predictors/3]]
	
	#compare predictors
	if random.random() < 0.2*threat[outcome+1]+0.1:
		output = random.choice(['R','P','S'])
	else:
		output = predictors[predictorscore.index(max(predictorscore))]

oldpredictors = predictors