rmf

AuthorAnonymous
Submission date2020-02-10 02:35:02.278803
Rating7497
Matches played200
Win rate77.0

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

Source code:

import random

A={'RR':'1','RP':'2','RS':'3','PR':'4','PP':'5','PS':'6','SR':'7','SP':'8','SS':'9'}
B={'RR':'R','RP':'R','RS':'S','PR':'R','PP':'P','PS':'P','SR':'S','SP':'P','SS':'S'}
C={'R':'P','P':'S','S':'R'}
R=range
I=input
if not I:
   D=[""]*3
   E=[random.choice("RPS")]*18
   F=[random.choice("RPS")]*6
   G=[[0]*18,[0]*18,[0]*18,[0]*18,[0]*18,[0]*18]
   H=[0]*6
else:
   for j in R(18):
       for i in R(4):G[i][j]*=0.8
       for i in R(4,6):G[i][j]*=0.5
       for i in R(0,6,2):G[i][j]-=(I==C[C[E[j]]]);G[i+1][j]-=(output==C[C[E[j]]])
       for i in R(2,6,2):G[i][j]+=(I==E[j]);G[i+1][j]+=(output==E[j])
       G[0][j]+=1.3*(I==E[j])-0.3*(I==C[E[j]])
       G[1][j]+=1.3*(output==E[j])-0.3*(output==C[E[j]])
   for i in R(6):H[i]=0.9*H[i]+(I==F[i])-(I==C[C[F[i]]])
   D[0]+=I
   D[1]+=output
   D[2]+=A[I+output]
   for i in R(3):
       j=min(21,len(D[2]))
       k=-1
       while j>1 and k<0:j-=1;k=D[i].rfind(D[i][-j:],0,-1)
       E[2*i]=D[0][j+k]
       E[2*i+1]=C[D[1][j+k]]
       k=D[i].rfind(D[i][-j:],0,j+k-1)
       E[2*i]=B[E[2*i]+D[0][j+k]]
       E[2*i+1]=B[E[2*i+1]+C[D[1][j+k]]]
   for i in R(6,18):E[i]=C[E[i-6]]
   for i in R(0,6,2):F[i]=E[G[i].index(max(G[i]))];F[i+1]=C[E[G[i+1].index(max(G[i+1]))]]
output=C[F[H.index(max(H))]]