# Nebelwerfer 3

This program has been disqualified.

 Author dllu Submission date 2011-05-24 00:36:37.276127 Rating 6796 Matches played 206 Win rate 67.96

## Source code:

``````import random

lastmatch =0
lastmatch1=0
lastmatch2=0

limit = 40

predictors=range(6)

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

if not input:
oldpredictors=range(6)
urmoves=""
mymoves=""
output=random.choice(['R','P','S'])
predictorscore=[1.2,0.7,0.7,0.6,0.6,0.6]
else:
for i in range(6):
predictorscore[i]*=0.8
predictorscore[i]+=(input==oldpredictors[i])/9.0
predictorscore[i]-=(input=={'R':'S', 'P':'R', 'S':'P'}[oldpredictors[i]])/10.0

#Predictor 0-11: History matching
urmoves+=input
done=0
done1=0
done2=0
for i in range(len(urmoves)-1,limit+1,-1):
match=0
j=1
while j<=i and mymoves[i-j]==mymoves[len(urmoves)-j] and urmoves[i-j]==urmoves[len(urmoves)-j] and not done:
match+=1
if match>lastmatch:
lastmatch=match
predictors[0]=urmoves[i]
predictors[1]=mymoves[i]
if match>limit:
done=1
break
j+=1
match=0
j=1
while j<=i and mymoves[i-j]==mymoves[len(urmoves)-j] and not done1:
match+=1
if match>lastmatch1:
lastmatch1=match
predictors[2]=urmoves[i]
predictors[3]=mymoves[i]
if match>limit:
done1=1
break
j+=1
match=0
j=1
while j<=i and urmoves[i-j]==urmoves[len(urmoves)-j] and not done2:
match+=1
if match>lastmatch2:
lastmatch2=match
predictors[4]=urmoves[i]
predictors[5]=mymoves[i]
if match>limit:
done2=1
break
j+=1

predictors[1]={'R':'S', 'P':'R', 'S':'P'}[predictors[1]]
predictors[3]={'R':'S', 'P':'R', 'S':'P'}[predictors[3]]
predictors[5]={'R':'S', 'P':'R', 'S':'P'}[predictors[5]]

#compare predictors
best=-100
for i in range(6):
if predictorscore[i]>best:
output = predictors[i]
best = predictorscore[i]

output = {'R':'P','P':'S','S':'R'}[output] #attempt to win
if(len(mymoves)%17==11):
output = random.choice(['R','P','S'])
mymoves+=output

for i in range(6):
oldpredictors[i]=predictors[i]``````