RockBot_v2

This program has been disqualified.


AuthorJustinF
Submission date2011-06-14 07:57:26.034256
Rating2280
Matches played2447
Win rate21.82

Source code:

def leastLikely(next, inputs):
  outcomes = [0, 0, 0]
  for x in xrange(len(inputs)):
    key = inputs[x:]
    found = next.get(key, dict())
    outcomes[0] += found.get('R', 0)
    outcomes[1] += found.get('P', 0)
    outcomes[2] += found.get('S', 0)
  if outcomes[0] <= outcomes[1] and outcomes[0] <= outcomes[2]:
    return "R"
  if outcomes[1] <= outcomes[0] and outcomes[1] <= outcomes[2]:
    return "P"
  if outcomes[2] <= outcomes[0] and outcomes[2] <= outcomes[1]:
    return "S"

def addToNext(next, inputs):
  length = len(inputs)
  if (length-1 < 50):
    for x in xrange(length-1):
      key1 = inputs[x:-1]
      key2 = inputs[-1]
      found1 = next.get(key1, dict())
      found2 = found1.get(key2, 0) + 1
      found1[key2] = found2
      next[key1] = found1
  else:
    for x in xrange(length-51, length-1):
      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 == "":
  next = dict()
  myStack = ""
else:
  myStack += input

addToNext(next, myStack)
output = leastLikely(next, myStack)