This program has been disqualified.
Author | dllu |
Submission date | 2011-05-24 00:44:58.118075 |
Rating | 7953 |
Matches played | 171 |
Win rate | 79.53 |
import random
lastmatch =0
lastmatch1=0
lastmatch2=0
limit = 40
predictors=range(6)
best=-100
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.87
if input==oldpredictors[i]:
predictorscore[i]+=0.11
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
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':'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]]
#compare predictors
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 or best<0:
output = random.choice(['R','P','S'])
mymoves+=output
for i in range(6):
oldpredictors[i]=predictors[i]