This program has been disqualified.
| Author | JustinF | 
| Submission date | 2011-06-15 13:24:16.863109 | 
| Rating | 5308 | 
| Matches played | 2370 | 
| Win rate | 55.02 | 
import random
MAX_LENGTH = 50
def likely(next, inputs):
  outcomes = [[0, 'R'], [0, 'P'], [0, 'S']]
  tmpInputs = inputs[-MAX_LENGTH:]
  for x in xrange(len(tmpInputs)):
    key = inputs[x:]
    found = next.get(key, dict())
    outcomes[0][0] += found.get('R', 0)
    outcomes[1][0] += found.get('P', 0)
    outcomes[2][0] += found.get('S', 0)
  return outcomes
def addToNext(next, inputs):
  length = len(inputs) - 1
  tmpInputs = inputs[-(MAX_LENGTH+1):]
  for x in xrange(len(tmpInputs) - 2):
    key1 = inputs[x:-1]
    key2 = inputs[-1]
    found1 = next.get(key1, dict())
    found2 = found1.get(key2, 0) + 1
    found1[key2] = found2
    next[key1] = found1
if input == "":
  myNext = dict()
  oppNext = dict()
  myStack = ""
  oppStack = ""
  fails = 0
  wins = 0
else:
  oppStack += input
beats = {'P': 'S', 'R': 'P', 'S':'R'}
addToNext(oppNext, oppStack)
oppChoices = likely(oppNext, oppStack)
addToNext(myNext, myStack)
myChoices = likely(myNext, myStack)
if myStack:
  if beats[myStack[-1]] == oppStack[-1]:
    fails += 1
  elif beats[oppStack[-1]] == myStack:
    wins += 1
if wins > fails + 10:
  output = random.choice(('R', 'P', 'S'))
else:
  choices = sorted([[myChoices[0][0] - oppChoices[2][0], 'R'], [myChoices[1][0] - oppChoices[0][0], 'P'], [myChoices[2][0] - oppChoices[1][0], 'S']])
  if choices[0][0] == choices[1][0] == choices[2][0]:
    output = random.choice(('R', 'P', 'S'))
  elif choices[0][0] == choices[1][0]:
    output = random.choice((choices[0][1], choices[1][1]))
  else:
    output = choices[0][1]
myStack += output