This program has been disqualified.
Author | EbTech |
Submission date | 2011-05-25 19:47:38.435405 |
Rating | 6066 |
Matches played | 3394 |
Win rate | 54.74 |
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
heatR = heatP = heatS = 0
coldR = coldP = coldS = 0
while index < len(matchHistory)-2 and itr <= 300:
index2 = index
index3 = len(matchHistory)-2
itr += 1
while index2 >= max(0, index - 20) and matchHistory[index2] == matchHistory[index3] and matchHistory[index2+1] == matchHistory[index3+1]:
index2 -= 2
index3 -= 2
itr += 1
energy = (index-index2)/2 + 1
energy = math.pow(energy , math.log(energy)+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