Thwomp?

This program has been disqualified.


AuthorEbTech
Submission date2011-05-25 17:56:40.245073
Rating10000
Matches played1
Win rate100.0

Source code:

import math
import random

if input == "":
	matchHistory = ""
        candidate = ['P','R','P','S','R','P','S']
        score = [0,2,0,0,0,0,2]
else:
	matchHistory += input
	for i in range(7):
		score[i] *= 0.96
		score[i] += (4 + {'R':0,'P':1,'S':2}[candidate[i]] - {'R':0,'P':1,'S':2}[input])%3 - 1
        
	index = 0
        itr = 0
	limit = 15
        itrlimit = 400
	heatR = heatP = heatS = 0
	coldR = coldP = coldS = 0
	while index < len(matchHistory)-2 and itr < itrlimit:
		index2 = index
		index3 = len(matchHistory)-2
		length = 0
		while index2 >= 0 and length <= limit:
			if matchHistory[index2] != matchHistory[index3] or matchHistory[index2+1] != matchHistory[index3+1]:
				break
			index2 -= 2
			index3 -= 2
			length += 1
                        itr += 1
		energy = math.pow(length+1, math.log(length+1)+1)
		predict = matchHistory[index+3]
		if predict == 'R':
				heatP += energy
				heatS -= energy
		elif predict == 'P':
				heatS += energy
				heatR -= energy
		else:
				heatR += energy
				heatP -= energy
		predict = matchHistory[index+2]
		if predict == 'R':
				coldP += energy
				coldS -= energy
		elif predict == 'P':
				coldS += energy
				coldR -= energy
		else:
				coldR += energy
				coldP -= energy
		index += 2
        
	candidate[0] = random.choice(['R','P','S'])
	if heatR > heatP and heatR > heatS:
		candidate[1] = "R"
	elif heatP > heatS:
		candidate[1] = "P"
	else:
		candidate[1] = "S"
	if coldR > coldP and coldR > coldS:
		candidate[4] = "R"
	elif coldP > coldS:
		candidate[4] = "P"
	else:
		candidate[4] = "S"
	for i in [2,3,5,6]:
		candidate[i] = {'R':'S','P':'R','S':'P'}[candidate[i-1]]

best = score[0]
output = candidate[0]
for i in range(1, 7):
	if (best < score[i]):
		best = score[i]
		output = candidate[i]
matchHistory += output