RPS_FA_Test

AuthorTeleZ
Submission date2017-12-29 23:17:19.522100
Rating7791
Matches played297
Win rate75.76

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':0,'P':1,'S':2}
i2k={0:'R',1:'P',2:'S'}

def mdl(N):
    N%=3
    if N<0:
       N+=3
    return N

if not input:
   DNA=[""]*3
   subs=[0]*6
   prin=[[0]*6]*3
   meta=[0]*3
   output=random.choice("RPS")
else:
   if len(DNA[2])>0:
      for i in range(3):
          k=mdl(subs[prin[i].index(max(prin[i]))]-k2i[input])
          if k==2:
             k=-1
          meta[i]=0.9*meta[i]+k
      for j in range(6):
          k=mdl(subs[j]-k2i[input])
          if k==2:
             k=-1
          prin[1][j]*=0.8
          prin[2][j]*=0.5
          for i in range(3):
              prin[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))
   output=i2k[mdl(subs[prin[i].index(max(prin[i]))])]