Smartie.1

AuthorJorge
Submission date2011-07-06 18:40:40.816202
Rating5644
Matches played4482
Win rate55.24

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

Source code:

import random

if input == "":
	plays = {"R": [],
			 "P": [],
			 "S": []}
	beats = {"R": "P","P": "S","S": "R"}
	shifted = beats
	output = random.choice(["R","P","S"])
else:
	plays[mylast].append(input)
	try:
		output = shifted[random.choice(plays[input])]
	except IndexError:
		output = random.choice(["R","P","S"])

	if beats[mylast] == input:
		shifted = {"R": shifted["P"], "P": shifted["S"], "S": shifted["R"]}

mylast = output