Doctor Robotnik

This program has been disqualified.


AuthorHyena oder
Submission date2011-06-11 00:22:24.941028
Rating6780
Matches played2650
Win rate72.45

Source code:

import random

lastmatch =0
lastmatch1=0
lastmatch2=0

limit = 6

best=-100



if not input:
	urmoves=""
	mymoves=""
	output=random.choice(['P'])
	predictorscore=[1.2,0.7,0.7,0.6,0.6,0.6,0,0,0,0,0,0,0,0]
	oldpredictors=predictors=['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(14):
		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
	
	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
					predictors[0]=urmoves[i]
					predictors[1]=mymoves[i]
				if match>limit:
					done=1
			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
					predictors[2]=urmoves[i]
					predictors[3]=mymoves[i]
				if match1>limit:
					done1=1
			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
					predictors[4]=urmoves[i]
					predictors[5]=mymoves[i]
				if match2>limit:
					done2=1
			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-12: Opponent plays like Predictor 1-6
	for i in range(7,12):
		predictors[i] = {'R':'S','P':'R','S':'P'}[predictors[i-6]]
	
	#Predictor 13: 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[12] = "R"
	elif paperRating>scissorsRating:
		predictors[12] = "P"
	else:
		predictors[12] = "S"
		
	#Predictor 14: 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[13] = "R"
	elif paperRating2>scissorsRating2:
		predictors[13] = "P"
	else:
		predictors[13] = "S"
		

	
	#compare predictors
	for i in range(14):
		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(14):
	oldpredictors[i]=predictors[i]