Algo Sniffer 2

Authordllu
Submission date2011-05-21 21:27:29.886322
Rating4080
Matches played7514
Win rate35.45

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

Source code:

import random
#fixed bug

if input=="":
	nummoves = 0
	mymoves = urmoves = [0,0,0]
	mode = 0

if nummoves < 3:
	move = random.randrange(0,3)
	if move==1:
		output = "R"
	elif move==2:
		output = "P"
	else:
		output = "S"
		
	mymoves[nummoves] = move	
	if input=="R":
		urmoves[nummoves] = 1
	elif input=="P":
		urmoves[nummoves] = 2
	else:
		urmoves[nummoves] = 3
	
	nummoves += 1
else:
	if mode==0:
		if urmoves[1]==mymoves[0] and urmoves[2]==mymoves[1]:
			mode=1
		elif urmoves[1]==mymoves[0]%3+1 and urmoves[2]==mymoves[1]%3+1:
			mode=2
		elif urmoves[1]==1 and urmoves[2]==1:
			mode=3
		elif mymoves[0]==urmoves[1]%3+1 and mymoves[1]==urmoves[2]%3+1:
			mode=4
		else:
			mode=5
	if mode==1:
		output = {'R':'P', 'P':'S', 'S':'R'}[lastoutput]
	elif mode==2:
		output = {'R':'S', 'P':'R', 'S':'P'}[lastoutput]
	elif mode==3:
		output = 'P'
	elif mode==4:
		output = {'R':'R', 'P':'P', 'S':'S'}[lastoutput]
	else:
		output = {'R':'P', 'P':'S', 'S':'R'}[input]
lastoutput = output