Author | testz |
Submission date | 2017-08-31 02:12:23.918360 |
Rating | 6992 |
Matches played | 342 |
Win rate | 72.22 |
Use rpsrunner.py to play unranked matches on your computer.
import random
kon={'RR':'1','RP':'2','RS':'3','PR':'4','PP':'5','PS':'6','SR':'7','SP':'8','SS':'9'}
d0s={'1':0,'2':0,'3':0,'4':1,'5':1,'6':1,'7':2,'8':2,'9':2}
d1s={'1':0,'2':1,'3':2,'4':0,'5':1,'6':2,'7':0,'8':1,'9':2}
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=""
flag=False
subs=[0]*6
skor=[0]*6
output=random.choice("RPS")
else:
if flag:
for i in range(6):
skor[i]*=0.9
j=mdl(subs[i]-k2i[input])
if j==1:
skor[i]+=j
else:
skor[i]-=1
DNA+=kon[input+output]
i=min(11,len(DNA))
j=-1
while i>1 and j<0:
i-=1
RNA=DNA[-i:]
j=DNA.rfind(RNA,0,-1)
flag=(j>=0)
output=random.choice("RPS")
if flag:
for k in range(3):
subs[k]=mdl(d0s[DNA[i+j]]-k+1)
subs[k+3]=mdl(d1s[DNA[i+j]]-k-1)
output=i2k[subs[skor.index(max(skor))]]