High-bypass turbofan

This program has been disqualified.


Authordllu
Submission date2011-05-25 18:24:37.582762
Rating3761
Matches played4570
Win rate33.13

Source code:

import random

lastmatch=0
limit = 23

if not input:
	urmoves=""
	mymoves=""
	output = random.choice(['R','P','S'])
	oldpredictors=predictors=['P','P','P']
	predictorscore=[3,2,1]
else:
	for i in range(3):
		predictorscore[i]*=0.87
		if input==oldpredictors[i]:
			predictorscore[i]+=0.12
		elif input=={'R':'S', 'P':'R', 'S':'P'}[oldpredictors[i]]:
			predictorscore[i]-=0.10
		else:
			predictorscore[i]-=0.03
	output = random.choice(['R','P','S'])
	urmoves+=input
	for i in range(len(urmoves)-1,limit+1,-1):
		match=0
		j=1
		while mymoves[i-j]==mymoves[len(urmoves)-j]:
			match+=1
			if match>lastmatch:
				lastmatch=match
				if match>limit:
					output=urmoves[i]
					break
			j+=1
			
		if match>limit:
			break
			
	for i in range(1,3):
		predictors[i] = {'R':'S','P':'R','S':'P'}[predictors[i-1]]
	best = -1
	for i in range(3):
		if predictorscore[i]>best:
			output = predictors[i]
			best = predictorscore[i]
	if len(mymoves)%101==11 or best<0:
		output = random.choice(['R','P','S'])			
	output = {'R':'P','P':'S','S':'R'}[output]

mymoves+=output

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