This program has been disqualified.
Author | Blackadder |
Submission date | 2011-06-18 07:58:31.116058 |
Rating | 7932 |
Matches played | 527 |
Win rate | 81.02 |
#Darwin v1 by Blackadder
#This is a based on the DNA werfer by dllu
import random
old_number_of_predictors = 54
new_number_of_predictors = 72
number_of_predictors = old_number_of_predictors + new_number_of_predictors
predictors=range(number_of_predictors)
for i in range(number_of_predictors):
predictors[i]=random.choice(['R','P','S'])
if not input:
limits = [5,15,30]
beat={'R':'P','P':'S','S':'R'}
urmoves=""
mymoves=""
mymoves2 = ""
DNAmoves=""
DNAmoves2=""
output=random.choice(['R','P','S'])
output2 = output
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
#History matching
urmoves+=input
mymoves+=output
mymoves2+=output2
DNAmoves+=nuclease[input+output]
DNAmoves2+=nuclease[input+output2]
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+14*z] = urmoves[j+i]
predictors[1+14*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+14*z] = urmoves[j+i]
predictors[3+14*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+14*z] = urmoves[j+i]
predictors[5+14*z] = beat[mymoves[j+i]]
j=limit
while j>=1 and not DNAmoves2[length-j:length] in DNAmoves2[0:length-1]:
j-=1
if j>=1:
i = DNAmoves2.rfind(DNAmoves2[length-j:length],0,length-1)
predictors[6+14*z] = urmoves[j+i]
predictors[7+14*z] = beat[mymoves2[j+i]]
j=limit
while j>=1 and not mymoves2[length-j:length] in mymoves2[0:length-1]:
j-=1
if j>=1:
i = mymoves2.rfind(mymoves2[length-j:length],0,length-1)
predictors[8+14*z] = urmoves[j+i]
predictors[9+14*z] = beat[mymoves2[j+i]]
j=limit
while j>=1 and not DNAmoves2[length-j:length] in DNAmoves2[0:length-1]:
j-=1
if j>=1:
i = DNAmoves2.rfind(DNAmoves2[length-j:length],0,length-1)
predictors[10+14*z] = urmoves[j+i]
predictors[11+14*z] = beat[mymoves[j+i]]
j=limit
while j>=1 and not mymoves2[length-j:length] in mymoves2[0:length-1]:
j-=1
if j>=1:
i = mymoves2.rfind(mymoves2[length-j:length],0,length-1)
predictors[12+14*z] = urmoves[j+i]
predictors[13+14*z] = beat[mymoves[j+i]]
for i in range(number_of_predictors/3,number_of_predictors):
predictors[i]=beat[beat[predictors[i-18]]]
#compare predictors
output2 = beat[predictors[predictorscore.index(max(predictorscore))]]
output = output2
if 3==random.randint(1, 5):
output=random.choice(['R','P','S'])
oldpredictors=predictors