# Flammenwerfer 6

This program has been disqualified.

 Author dllu Submission date 2011-05-24 08:10:24.291209 Rating 9147 Matches played 129 Win rate 91.47

## Source code:

``````#This is a flammenwerfer. It werfs flammen.

import random
import math

lastmatch =0
lastmatch1=0
lastmatch2=0
heatR=heatP=heatS=[0,0,0,0,0,0]

predictors=range(26)

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

if not input:
oldpredictors=range(26)
urmoves=""
mymoves=""
output=random.choice(['R','P','S'])
predictorscore=[1.2,0.7,0.7,0.6,0.6,0.6,0.1,0.1,0.1,0.1,0.1,0.1,0,0,0,0,0,0,0,0,0,0,0,0,0,-0.1]

rockRating = scissorsRating = paperRating = 0
rockRating2 = scissorsRating2 = paperRating2 = 0
else:
if len(mymoves)<40:
limit = len(mymoves)
else:
limit = 40

#limit = 30

for i in range(26):
predictorscore[i]*=0.88
if input==oldpredictors[i]:
predictorscore[i]+=0.14
elif input=={'R':'S', 'P':'R', 'S':'P'}[oldpredictors[i]]:
predictorscore[i]-=0.10
else:
predictorscore[i]-=0.03

#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
predictur=random.choice(['R','P','S'])
predictmy=random.choice(['R','P','S'])
while j<=i and mymoves[i-j]==mymoves[len(urmoves)-j] and urmoves[i-j]==urmoves[len(urmoves)-j]:
match+=1
if match>lastmatch:
lastmatch=match
if not done:
predictors[0]=urmoves[i]
if not done:
predictors[1]=mymoves[i]
predictur = urmoves[i]
predictmy = mymoves[i]
if match>limit:
done=1
break
j+=1

energy = math.pow(match+1,math.log(match+1)+1)
if predictur=='R':
heatR[0]+=energy
heatP[0]-=energy
elif predictur=='P':
heatP[0]+=energy
heatS[0]-=energy
else:
heatS[0]+=energy
heatR[0]-=energy
if predictmy=='R':
heatR[1]+=energy
heatP[1]-=energy
elif predictmy=='P':
heatP[1]+=energy
heatS[1]-=energy
else:
heatS[1]+=energy
heatR[1]-=energy

match=0
j=1
while j<=i and mymoves[i-j]==mymoves[len(urmoves)-j]:
match+=1
if match>lastmatch1:
lastmatch1=match
if not done1:
predictors[2]=urmoves[i]
if not done1:
predictors[3]=mymoves[i]
predictur = urmoves[i]
predictmy = mymoves[i]
if match>limit:
done1=1
break
j+=1
energy = math.pow(match+1,math.log(match+1)+1)
if predictur=='R':
heatR[2]+=energy
heatP[2]-=energy
elif predictur=='P':
heatP[2]+=energy
heatS[2]-=energy
else:
heatS[2]+=energy
heatR[2]-=energy
if predictmy=='R':
heatR[3]+=energy
heatP[3]-=energy
elif predictmy=='P':
heatP[3]+=energy
heatS[3]-=energy
else:
heatS[3]+=energy
heatR[3]-=energy
match=0
j=1
while j<=i and urmoves[i-j]==urmoves[len(urmoves)-j]:
match+=1
if match>lastmatch2:
lastmatch2=match
if not done2:
predictors[4]=urmoves[i]
if not done2:
predictors[5]=mymoves[i]
predictur = urmoves[i]
predictmy = mymoves[i]
if match>limit:
done2=1
break
j+=1
energy = math.pow(match+1,math.log(match+1)+1)
if predictur=='R':
heatR[4]+=energy
heatP[4]-=energy
elif predictur=='P':
heatP[4]+=energy
heatS[4]-=energy
else:
heatS[4]+=energy
heatR[4]-=energy
if predictmy=='R':
heatR[5]+=energy
heatP[5]-=energy
elif predictmy=='P':
heatP[5]+=energy
heatS[5]-=energy
else:
heatS[5]+=energy
heatR[5]-=energy

predictors[1]={'R':'P','P':'S','S':'R'}[predictors[1]]
predictors[3]={'R':'P','P':'S','S':'R'}[predictors[3]]
predictors[5]={'R':'P','P':'S','S':'R'}[predictors[5]]
for i in range(6,12):
if heatR[i-6]>heatP[i-6] and heatR[i-6]>heatS[i-6]:
predictors[i]='R'
elif heatP[i-6]>heatS[i-6]:
predictors[i]='P'
else:
predictors[i]='S'
predictors[7]={'R':'P','P':'S','S':'R'}[predictors[7]]
predictors[9]={'R':'P','P':'S','S':'R'}[predictors[9]]
predictors[11]={'R':'P','P':'S','S':'R'}[predictors[11]]

#Predictor 13-24: Opponent tries to beat someone who predicts with 1-12
for i in range(12,24):
predictors[i] = {'R':'S','P':'R','S':'P'}[predictors[i-12]]

#Predictor 25: Opponent plays like Boltzmann counter
rockRating *= 0.95
scissorsRating *= 0.95
paperRating *= 0.95
if mymoves[len(mymoves)-1] == "R":
paperRating += 0.1
scissorsRating -= 0.1
elif mymoves[len(mymoves)-1] == "P":
scissorsRating += 0.1
rockRating -= 0.1
elif mymoves[len(mymoves)-1] == "S":
rockRating += 0.1
paperRating -= 0.1
if rockRating>scissorsRating and rockRating>paperRating:
predictors[24] = "R"
elif paperRating>scissorsRating:
predictors[24] = "P"
else:
predictors[24] = "S"

rockRating2 *= 0.95
scissorsRating2 *= 0.95
paperRating2 *= 0.95
if input=='R':
rockRating2+=0.1
paperRating2-=0.1
elif input=='P':
paperRating2+=0.1
scissorsRating2-=0.1
else:
scissorsRating2+=0.1
rockRating2=0.1
if rockRating2>scissorsRating2 and rockRating2>paperRating2:
predictors[25] = "R"
elif paperRating2>scissorsRating2:
predictors[25] = "P"
else:
predictors[25] = "S"

#compare predictors
best=-1
for i in [0,2,4,6,8,10,1,3,5,7,9,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]:
if predictorscore[i]>best:
output = predictors[i]
best = predictorscore[i]

if best<-0.5 or len(mymoves)%23==11:
output=random.choice(['R','P','S'])

output = {'R':'P','P':'S','S':'R'}[output] #attempt to win
mymoves+=output

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