This program has been disqualified.
Author | dllu |
Submission date | 2011-05-24 03:57:49.332854 |
Rating | 9083 |
Matches played | 109 |
Win rate | 90.83 |
#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(24)
for i in range(24):
predictors[i]=random.choice(['R','P','S'])
if not input:
oldpredictors=range(24)
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]
else:
if len(mymoves)<40:
limit = len(mymoves)
else:
limit = 40
#limit = 30
for i in range(24):
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]]
for i in range(12,24):
predictors[i] = {'R':'S','P':'R','S':'P'}[predictors[i-12]]
#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]:
if predictorscore[i]>best:
output = predictors[i]
best = predictorscore[i]
if best<-0.5:
output=random.choice(['R','P','S'])
output = {'R':'P','P':'S','S':'R'}[output] #attempt to win
mymoves+=output
for i in range(24):
oldpredictors[i]=predictors[i]