This program has been disqualified.
Author | EbTech |
Submission date | 2011-05-25 18:53:52.681517 |
Rating | 8182 |
Matches played | 22 |
Win rate | 81.82 |
import math
import random
if input == "":
matchHistory = ""
candidate = ['P','R','P','S','R','P','S']
score = [1,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
candidate[0] = random.choice(['R','P','S'])
index = 0
itr = 0
longestMatch = -1
while index < len(matchHistory)-2 and itr <= 500 and longestMatch <= 20:
index2 = index
index3 = len(matchHistory)-2
length = 0
itr += 1
while index2 >= 0 and length <= 20 and matchHistory[index2] == matchHistory[index3] and matchHistory[index2+1] == matchHistory[index3+1]:
itr += 1
index2 -= 2
index3 -= 2
length += 1
if length > longestMatch:
longestMatch = length
candidate[1] = matchHistory[index+3]
candidate[4] = matchHistory[index+2]
index += 2
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