cb5

AuthorAnonymous
Submission date2020-02-03 01:54:16.996364
Rating7141
Matches played203
Win rate72.91

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

Source code:

import random;a=60;b=12
x=random.choice;z=range;A=max
if not input:c=[50,20,6];d={'R':'P','P':'S','S':'R'};e="";f="";g="";h=[x("RPS")]*b;i=[3]*a;j=[3]*a;k=[3]*a;l=[3]*a;m={'RP':'a','PS':'b','SR':'c','PR':'d','SP':'e','RS':'f','RR':'g','PP':'h','SS':'i'};n=0;o=[x("RPS")]*a;p=[x("RPS")]*b;q=[3]*b
else:
  for r in z(a):
    i[r]*=0.8;i[r]+=(input==o[r])*3;i[r]-=(input==d[d[o[r]]])*3;j[r]*=0.8;j[r]+=(output==o[r])*3;j[r]-=(output==d[d[o[r]]])*3;k[r]+=(input==o[r])*3
    if input==d[d[o[r]]]:k[r]=0
    l[r]+=(output==o[r])*3
    if output==d[d[o[r]]]:l[r]=0
  for r in z(b):q[r]*=0.959;q[r]+=(input==p[r])*3;q[r]-=(input==d[d[p[r]]])*3
  e+=input;f+=output;g+=m[input+output];n+=1
  for s in z(3):
    t=min([n,c[s]]);u=t
    while u>=1 and not g[n-u:n]in g[0:n-1]:u-=1
    if u>=1:r=g.rfind(g[n-u:n],0,n-1);o[0+6*s]=e[u+r];o[1+6*s]=d[f[u+r]]
    u=t
    while u>=1 and not e[n-u:n]in e[0:n-1]:u-=1
    if u>=1:r=e.rfind(e[n-u:n],0,n-1);o[2+6*s]=e[u+r];o[3+6*s]=d[f[u+r]]
    u=t
    while u>=1 and not f[n-u:n]in f[0:n-1]:u-=1
    if u>=1:r=f.rfind(f[n-u:n],0,n-1);o[4+6*s]=e[u+r];o[5+6*s]=d[f[u+r]]
  v=len(f);r=g.rfind(g[v-u:v-1],0,v-2)
  while r==-1:
    u-=1;r=g.rfind(g[v-u:v-1],0,v-2)
    if u<2:break
  if r==-1 or u+r>=v:o[18]=o[19]=d[x(e)]
  else:o[18]=d[f[u+r]];o[19]=e[u+r]
  for r in z(20,60):o[r]=d[d[o[r-20]]]
  p[0]=o[i.index(A(i))];p[1]=d[o[j.index(A(j))]];p[2]=o[k.index(A(k))];p[3]=d[o[l.index(A(l))]]
  for r in z(4,12):p[r]=d[p[r-4]]
output=d[p[q.index(A(q))]]
if A(q)<0:output=d[x(e)]