test2559markov(fixed)

Authortrollathon
Submission date2013-11-14 19:19:07.550990
Rating5964
Matches played666
Win rate58.41

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

Source code:

if input == "":
	import random
	order = 3
	history = ""
	output = random.choice(["R", "P", "S"])
else:
	history += input
	if len(history) >= order:
		search = history[-order:]
		mplace = history.rfind(search, 0, len(history)-3)
		predict = history[mplace+3]
		if predict == "R":
			output = "P"
		elif predict == "P":
			output = "S"
		elif predict == "S":
			output = "R"
		else:
			output = random.choice(["R","P","S"])
	else:
		output = random.choice(["R","P","S"])