history3

This program has been disqualified.


Authorlut-ze
Submission date2011-06-11 07:14:41.679098
Rating6587
Matches played2740
Win rate62.23

Source code:

import random
if input == "":
   history = ""
   longest_substr = 0
   output = random.choice(["R","P","S"])
else:
   history += input
   output = do_history()
   if len(history) > 2 :
      move = do_history()
      output = {"R":"P", "P":"S", "S":"R"}[move]
   else:
      output = random.choice(["R","P","S"])

def do_history():
   next = "R"
   if (len(history) > 100):
      max_len = 100
   else:
      max_len = len(history)
   for i in range(1,max_len) :
      substr = history[-i:]
      if history.count(substr)> 1:
         next = history[history.index(substr)+len(substr)]
   return next