Predictor V2

This program has been disqualified.


AuthorByron Knoll
Submission date2011-06-11 06:14:02.937521
Rating7761
Matches played67
Win rate77.61

Source code:

import random
if input=="":
	matchHistory = ""
	matchHistory2 = ""
else:
	matchHistory += input
	matchHistory2 += lastMove
prediction = random.choice(["R","P","S"])
index = 1
longestMatch = 0
limit = 50
while index < len(matchHistory)-1:
	index2 = index
	index3 = len(matchHistory)-1
	length = 0
	while index2 >= 0:
		if matchHistory[index2] != matchHistory[index3]:
			break
		index2 -= 1
		index3 -= 1
		length += 1
		if length > limit:
			break
	index2 = index
	index3 = len(matchHistory)-1
	while index2 >= 0:
		if matchHistory2[index2] != matchHistory2[index3]:
			break
		index2 -= 1
		index3 -= 1
		length += 1
		if length > limit:
			break
	if length > longestMatch:
		longestMatch = length
		prediction = matchHistory[index+1]
	if length > limit:
		break
	index += 1
output = {'R':'P', 'P':'S', 'S':'R'}[prediction]
if random.random() < 0.5:
	output = prediction
lastMove = output