RPS_MLA

AuthorTeleZ
Submission date2017-12-31 01:52:18.979450
Rating6872
Matches played317
Win rate71.29

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

Source code:

import random

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

def mdl(N):
    N%=3
    if N==-2:
       N=1
    elif N==2:
       N=-1
    return N

if not input:
   DNA=[""]*3
   taxi=[0]*3
   subs=[0]*6
   pre1=[[0]*3]*3
   pre2=[[0]*6]*3
   meta=[0]*3
   output=random.choice("RPS")
else:
   if len(DNA[2])>0:
      for i in range(3):
          j=mdl(taxi[pre1[i].index(max(pre1[i]))]-k2i[input])
          k=mdl(subs[pre2[i].index(max(pre2[i]))]-k2i[input])
          if abs(k-j)==2:
             j=0
          meta[i]=0.9*meta[i]+j
      for j in range(3):
          k=mdl(taxi[j]-k2i[input])
          pre1[1][j]*=0.8
          pre1[2][j]*=0.5
          for i in range(3):
              pre1[i][j]+=k
      for j in range(6):
          k=mdl(subs[j]-k2i[input])
          pre2[1][j]*=0.8
          pre2[2][j]*=0.5
          for i in range(3):
              pre2[i][j]+=k
   DNA[0]+=input
   DNA[1]+=output
   DNA[2]+=kon[input+output]
   i=min(26,len(DNA[2]))
   j=-1
   while i>1 and j<0:
         i-=1
         RNA=DNA[2][-i:]
         j=DNA[2].rfind(RNA,0,-1)
   if j<0:
      k=random.randint(0,len(DNA[2])-1)
   else:
      k=i+j
   for i in range(2):
       for j in range(3):
           subs[3*i+j]=k2i[DNA[i][k]]-j+i+1
   i=meta.index(max(meta))
   k=subs[pre2[i].index(max(pre2[i]))]
   for j in range(3):
       taxi[j]=k-j
   output=i2k[mdl(taxi[pre1[i].index(max(pre1[i]))])]