RPS_MLA_Rnd

AuthorTeleZ
Submission date2017-12-31 12:48:44.938290
Rating7332
Matches played315
Win rate70.79

Use rpsrunner.py to play unranked matches on your computer.

Source code:

import random

k2i={'RR':0,'RP':1,'RS':-1,'PR':-1,'PP':0,'PS':1,'SR':1,'SP':-1,'SS':0}
mix={'RR':'1','RP':'2','RS':'3','PR':'4','PP':'5','PS':'6','SR':'7','SP':'8','SS':'9'}
win={'1':'P','2':'P','3':'P','4':'S','5':'S','6':'S','7':'R','8':'R','9':'R'}
rot={'R':'S','S':'P','P':'R'}

if not input:
   DNA=""
   meta=[""]*3
   skor=[0]*3
else:
   if DNA:
      for i in range(3):
          skor[i]=0.9*skor[i]+k2i[input+meta[i]]
   DNA+=mix[input+output]
   i=min(26,len(DNA))
   j=-1
   while i>1 and j<0:
         i-=1
         j=DNA.rfind(DNA[-i:],0,-1)
   if j<0:
      meta[0]=win[DNA[random.randint(0,len(DNA)-1)]]
   else:
      meta[0]=win[DNA[i+j]]
   for i in range(1,3):
       meta[i]=rot[meta[i-1]]
if min(skor)<-2.7:
   output=meta[skor.index(max(skor))]
else:
   output=random.choice("RPS")