Nebelwerfer Medium

This program has been disqualified.


Authordllu
Submission date2011-06-14 17:31:08.583299
Rating7750
Matches played112
Win rate90.18

Source code:

import random

lastmatch =0
lastmatch1=0
lastmatch2=0

limit = 8

predictors=range(18)

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

if not input:
	oldpredictors=range(18)
	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.1,0.1,0.1,0.1,0.1,0.1]
else:
	for i in range(18):
		predictorscore[i]*=0.8
		predictorscore[i]+=(input==oldpredictors[i])/10.0
		predictorscore[i]-=(input=={'R':'S', 'P':'R', 'S':'P'}[oldpredictors[i]])/10.0
	
	#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]]
	for i in range(6,18):
		predictors[i]={'R':'S', 'P':'R', 'S':'P'}[predictors[i-6]]
		

	
	#compare predictors
	best=-100
	for i in range(18):
		if predictorscore[i]>best:
			output = predictors[i]
			best = predictorscore[i]
			
output = {'R':'P','P':'S','S':'R'}[output] #attempt to win			
mymoves+=output

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