DNA werfer 9

This program has been disqualified.


Authordllu
Submission date2011-06-21 06:07:03.941324
Rating7450
Matches played2239
Win rate72.85

Source code:

import random

number_of_predictors = 54 #yes, this really has 54 predictors.

predictors=range(number_of_predictors)

for i in range(number_of_predictors):
	predictors[i]=random.choice(['R','P','S'])

if not input:
	limits = [42,17,6]
	beat={'R':'P','P':'S','S':'R'}
	urmoves=""
	mymoves=""
	DNAmoves=""
	output=random.choice(['R','P','S'])
	predictorscore=range(number_of_predictors)
	nuclease={'RP':'a','PS':'b','SR':'c','PR':'d','SP':'e','RS':'f','RR':'g','PP':'h','SS':'i'}
	length=0
else:
	for i in range(number_of_predictors):
		predictorscore[i]*=0.8
		predictorscore[i]+=(input==oldpredictors[i])*3
		predictorscore[i]-=(input=={'R':'S', 'P':'R', 'S':'P'}[oldpredictors[i]])*3
		if predictorscore[i]<0:
			predictorscore[i]=0
	t=sum(predictorscore)
	for i in range(number_of_predictors):
		predictorscore[i]/=t
	
	#History matching
	urmoves+=input		
	mymoves+=output
	DNAmoves+=nuclease[input+output]
	length+=1
	
	for z in range(3):
		limit = min([length,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] = beat[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] = beat[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] = beat[mymoves[j+i]]
	
	for i in range(18,54):
		predictors[i]=beat[beat[predictors[i-18]]] #Trying to second guess me?
	
	#compare predictors
	b = random.random()
	for i in range(number_of_predictors):
		if b<=predictorscore[i]:
			output = beat[predictors[i]]
			break
		b-=predictorscore[i]

oldpredictors=predictors