Centrifugal Bumblepuppy 1003

Authordllu
Submission date2011-09-13 19:02:43.871440
Rating7644
Matches played2464
Win rate77.72

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

Source code:

#see also www.dllu.net/rps.html
import random
numPre = 18
numMeta = 6
if not input:
	limit = 8
	beat={'R':'P','P':'S','S':'R'}
	moves=['','','']
	pScore=[[3]*numPre,[3]*numPre,[3]*numPre,[3]*numPre,[3]*numPre,[3]*numPre]
	centrifuge={'RP':'a','PS':'b','SR':'c','PR':'d','SP':'e','RS':'f','RR':'g','PP':'h','SS':'i'}
	length=0
	p=[random.choice("RPS")]*numPre
	m=[random.choice("RPS")]*numMeta
	mScore=[3]*numMeta
else:
	for i in range(numPre):
		pScore[0][i]=0.8*pScore[0][i]+((input==p[i])-(input==beat[beat[p[i]]]))*3
		pScore[1][i]=0.8*pScore[1][i]+((output==p[i])-(output==beat[beat[p[i]]]))*3
		pScore[2][i]=0.87*pScore[2][i]+(input==p[i])*3.3-(input==beat[p[i]])*0.9-(input==beat[beat[p[i]]])*3
		pScore[3][i]=0.87*pScore[3][i]+(output==p[i])*3.3-(output==beat[p[i]])*0.9-(output==beat[beat[p[i]]])*3
		pScore[4][i]=(pScore[4][i]+(input==p[i])*3)*(1-(input==beat[beat[p[i]]]))
		pScore[5][i]=(pScore[5][i]+(output==p[i])*3)*(1-(output==beat[beat[p[i]]]))
	for i in range(numMeta):
		mScore[i]=(mScore[i]+(input==m[i]))*(1-(input==beat[beat[m[i]]]))
	moves[0]+=centrifuge[input+output]
	moves[1]+=input		
	moves[2]+=output
	length+=1
	for y in range(3):
		j=min([length,limit])
		while j>=1 and not moves[y][length-j:length] in moves[y][0:length-1]:
			j-=1
		i = moves[y].rfind(moves[y][length-j:length],0,length-1)
		p[0+2*y] = moves[1][j+i] 
		p[1+2*y] = beat[moves[2][j+i]] 
	
	for i in range(6,6*3):
		p[i]=beat[beat[p[i-6]]]
		
	for i in range(0,6,2):
		m[i]=       p[pScore[i  ].index(max(pScore[i  ]))]
		m[i+1]=beat[p[pScore[i+1].index(max(pScore[i+1]))]]
output = beat[m[mScore.index(max(mScore))]]
if max(mScore)<0.07 or random.randint(3,40)>length:
	output=beat[random.choice("RPS")]