This program has been disqualified.
Author | dllu |
Submission date | 2011-05-25 17:49:55.251155 |
Rating | 5884 |
Matches played | 4356 |
Win rate | 59.83 |
import random
lastmatch =0
lastmatch1=0
lastmatch2=0
limit = 12
best=-1
if not input:
urmoves=""
mymoves=""
output=random.choice(['R','P','S'])
predictorscore=[1.2,0.7,0.7,0.6,0.6,0.6,0.3,0.3,0.3,0.3,0.3,0.3,0,0,0,0,0,0,0.2,0.2]
oldpredictors=predictors=['P','P','P','P','P','P','P','P','P','P','P','P','P','P','P','P','P','P','P','P']
length=0
rockRating = scissorsRating = paperRating = 0
rockRating2 = scissorsRating2 = paperRating2 = 0
else:
for i in range(6):
predictors[i]=random.choice(['R','P','S'])
for i in range(20):
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 1-6: History matching
urmoves+=input
done=0
done1=0
done2=0
length+=1
for i in range(length-1,limit+1,-1):
match=0
match1=0
match2=0
fail=[0,0,0]
j=1
while j<=i:
if urmoves[i-j]==urmoves[length-j] and mymoves[i-j]==mymoves[length-j] and not (done or fail[0]):
match+=1
if match>lastmatch:
lastmatch=match
if match>limit:
done=1
predictors[0]=urmoves[i]
predictors[1]=mymoves[i]
elif not done:
match=0
fail[0]=1
if mymoves[i-j]==mymoves[length-j] and not (done1 or fail[1]):
match1+=1
if match1>lastmatch1:
lastmatch1=match1
if match1>limit:
done1=1
predictors[2]=urmoves[i]
predictors[3]=mymoves[i]
elif not done1:
match1=0
fail[1]=1
if urmoves[i-j]==urmoves[length-j] and not (done2 or fail[2]):
match2+=1
if match2>lastmatch2:
lastmatch2=match2
if match2>limit:
done2=1
predictors[4]=urmoves[i]
predictors[5]=mymoves[i]
elif not done2:
match2=0
fail[2]=1
if (done or fail[0]) and (done1 or fail[1]) and (done2 or fail[2]):
break
j+=1
if (done and done1 and done2) or (i<length-160):
break
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]]
#Predictor 7-18: Opponent plays like Predictor 1-12
for i in range(6,18):
predictors[i] = {'R':'S','P':'R','S':'P'}[predictors[i-6]]
#Predictor 19: 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[18] = "R"
elif paperRating>scissorsRating:
predictors[18] = "P"
else:
predictors[18] = "S"
#Predictor 20: I play like Boltzmann counter
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[19] = "R"
elif paperRating2>scissorsRating2:
predictors[19] = "P"
else:
predictors[19] = "S"
#compare predictors
for i in range(20):
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(20):
oldpredictors[i]=predictors[i]