Compactor 2

This program has been disqualified.


AuthorEbTech
Submission date2011-05-26 05:27:20.109696
Rating7500
Matches played56
Win rate75.0

Source code:

import math
import random

if not input:
	matchHistory = []
	candidate = ['P','R','P','S','R','P','S']
        score = [1,2,0,0,0,0,2]
else:
	matchHistory.append(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
	
candidate[0] = random.choice(['R','P','S'])
index = 0
itr = 0
longestMatch = -1

while index < len(matchHistory)-2 and itr <= 1000 and longestMatch <= 40:
	index2 = index
	index3 = len(matchHistory)-2
	length = 0
        itr += 2
	while index2 >= 0 and length <= 40 and matchHistory[index2] == matchHistory[index3] and matchHistory[index2+1] == matchHistory[index3+1]:
                itr += 1
		index2 -= 2
		index3 -= 2
		length += 1
	if length > longestMatch:
		longestMatch = length
		candidate[1] = matchHistory[index+3]
		candidate[4] = matchHistory[index+2]
	index += 2
        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.append(output)