This program has been disqualified.
Author | EbTech |
Submission date | 2011-05-23 17:40:57.995270 |
Rating | 5556 |
Matches played | 108 |
Win rate | 55.56 |
import math
import random
if input == "":
matchHistory = ""
candidate = ['P','P','P','P','P','P','P']
score = [0,0,0,0,0,0,0]
for i in range(0, 6):
candidate[i] = random.choice(['R','P','S'])
score[i] = random.random() - 0.5
else:
matchHistory += input
for i in range(0, 6):
score[i] *= 0.95
score[i] += (4 + {'R':0,'P':1,'S':2}[candidate[i]] - {'R':0,'P':1,'S':2}[input])%3 - 1
index = 0
limit = 50
heatR = heatP = heatS = 0
coldR = coldP = coldS = 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
energy = math.pow(length+1, math.log(length+1)+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 = 0
output = candidate[0]
for i in range(1, 6):
if (score[i] > score[best]):
best = i
output = candidate[i]
matchHistory += output