askljdhflaksjdfhals

This program has been disqualified.


AuthorTom
Submission date2014-04-28 01:16:38.325682
Rating3579
Matches played53
Win rate33.96

Source code:

import random
import collections

if not input:
    inputs=''
    outputs=''
    output = random.choice(["R","P","S"])


else:
    inputs += input
    lengthPattern = 3
    mutationProb = 0.1
    optimalMove = random.choice(["R","P","S"])
    optimalScore = 0.0
    optimalLength = 6.0
    weight = 1.0

    while lengthPattern > 1:
        weight = lengthPattern/6.0
        if len(inputs) < lengthPattern:
            lengthPattern -= 1
            continue
        countPattern = inputs[:-(lengthPattern)].count(inputs[-(lengthPattern):])
        pattern = inputs[-(lengthPattern):]
        index = inputs.index(pattern)
        if (index+lengthPattern) >= len(inputs):
            lengthPattern -= 1
            continue
        oppMove = inputs[(index+lengthPattern)]
        myMove = outputs[(index+lengthPattern)]
        i = 0
        while i < countPattern-1:
            index = inputs.index(pattern, index+lengthPattern)
            oppMove += inputs[(index+lengthPattern)]
            myMove += outputs[(index+lengthPattern)]
            i+=1
        score = 0.0
        for i in range(0,len(myMove)):
            if myMove[i]==oppMove[i]:
                score += 1.0
            elif (myMove[i]=='R' and oppMove[i]=='S') or (myMove[i]=='P' and oppMove[i]=='R') or (myMove[i]=='S' and oppMove[i]=='P'):
                score += 3.0
            else:
                score += 0.0
        score = score * weight
        if (score > optimalScore):
            optimalMove = 'R'
            optimalScore = score
            countR = myMove.count('R')
            countP = myMove.count('P')
            countS = myMove.count('S')
            maxCount = countR
            if countP > maxCount:
                maxCount = countP
                optimalMove = 'P'
            if countS > maxCount:
                maxCount = countR
        lengthPattern -= 1

    output = optimalMove

outputs += output