Iocane Compressor

This program has been disqualified.


AuthorByron Knoll
Submission date2011-05-26 01:43:46.871584
Rating6800
Matches played4534
Win rate63.94

Source code:

import random
if not input:
	matchHistory = ""
	count1 = count2 = count3 = 0
else:
	matchHistory += input
	if input == lastMove:
		offset += 1
	if (input=="R" and lastMove=="S") or (input=="P" and lastMove=="R") or (input=="S" and lastMove=="P"):
		offset += 2
	offset = offset%3
	if offset == 0:
		count1 += 1
	elif offset == 1:
		count2 += 1
	else:
		count3 += 1

prediction = random.choice(["R","P","S"])
index = 0
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
	if length > longestMatch:
		longestMatch = length
		prediction = matchHistory[index+1]
	if length > limit:
		break
	index += 1

if (count1 > count2) and (count1 > count3):
	offset = 0
	output = prediction
elif (count2 > count3):
	offset = 1
	output = {'R':'P', 'P':'S', 'S':'R'}[prediction]
else:
	offset = 2
	output = {'R':'S', 'P':'R', 'S':'P'}[prediction]
lastMove = output