Experimental 2

This program has been disqualified.


Authordllu
Submission date2011-07-08 22:20:25.314056
Rating6911
Matches played666
Win rate69.97

Source code:

import re
if not input:
	moves=''
	centrifuge={'RP':'a','PS':'b','SR':'c','PR':'d','SP':'e','RS':'f','RR':'g','PP':'h','SS':'i'}
	score=0
	length=0
else:
	moves+=centrifuge[input+output]
	length+=1
	if input==best:
		score-=1
	elif input==best0:
		score+=1
	
j=10
k={}
while j>=1 and not moves[length-j:length] in moves[0:length-1]:
	j-=1
for x in "abcdefghi":
	k[x] = len(re.findall(r'(?<=%s)(%s)' % (moves[length-j:length], x), moves[0:length-1]))
kR =k['a']+k['f']+k['g']
kP =k['b']+k['d']+k['h']
kS =k['c']+k['e']+k['i']
kR0=k['c']+k['d']+k['g']
kP0=k['a']+k['e']+k['h']
kS0=k['b']+k['f']+k['i']
best ="RPS"[[kR -kS ,kP -kR ,kS -kP ].index(max([kR -kS ,kP -kR ,kS -kP ]))]
best0="PSR"[[kR0-kS0,kP0-kR0,kS0-kP0].index(max([kR0-kS0,kP0-kR0,kS0-kP0]))]
if score<=0:
	output={'R':'P','P':'S','S':'R'}[best]
else:
	output={'R':'P','P':'S','S':'R'}[best0]