test_nazi_monkey1.1

This program has been disqualified.


Authorgaiasabre11
Submission date2011-05-24 06:35:11.162083
Rating4310
Matches played116
Win rate43.1

Source code:

import math
import random

r = random.randrange(0,100)

lastmatch=0

if input == "":
	matchHistory = ""
	urmoves=""
	mymoves=""
	output = random.choice(['R','P','S'])
else:
	matchHistory += input
	urmoves+=input
index = 0
limit = 60
heatR = heatP = heatS = 0
while index < len(matchHistory)-2:
	index2 = index
	index3 = len(matchHistory)-2
	length = 0
	while index2 >= 0:
		if matchHistory[index2] != matchHistory[index3] or matchHistory[index2+1] != matchHistory[index3+1]:
			break
		index2 -= 2
		index3 -= 2
		length += 1
		if length > limit:
			break
	predict = matchHistory[index+3]
        energy = math.pow(length+1, math.log(length+1)+1)
        if predict == 'R':
                heatP -= energy
                heatS += energy
        elif predict == 'P':
                heatS -= energy
                heatR += energy
        else:
                heatR -= energy
                heatP += energy
	index += 2
if heatR < heatP and heatR < heatS:
    output = "R"
elif heatP < heatS:
    output = "P"
else:
    output = "S"
    
if r<=60:
	output = random.choice(['R','P','S'])	
	for i in range(len(urmoves)-1,20,-1):
		match=0
		j=1
		while mymoves[i-j]==mymoves[len(urmoves)-j]:
			match+=1
			if match>lastmatch:
				lastmatch=match
				output=urmoves[i]
			if match>20:
				break
			j+=1
	
	output =  {'R':'P', 'P':'S', 'S':'R'}[output]

mymoves+=output    
    
matchHistory += output