IDontEvenKnowPython

AuthorShaunO
Submission date2011-06-09 09:05:40.579788
Rating4589
Matches played5518
Win rate41.34

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

Source code:

import random

if input == "":
	stack = []
elif input == "R":
	stack.append("R")
elif input == "P":
	stack.append("P")
elif input == "S":
	stack.append("S")

if len(stack) >= 5:
	rocks = stack.count("R")
	papers = stack.count("P")
	scissors = stack.count("S")
	stack = []
	if scissors < papers: 
		if scissors < rocks:
			output = "R"
		elif rocks < scissors:
			output = "P"
		else:
			output = random.choice(["R", "P", "S"])
	elif papers < rocks:
		if papers < scissors:
			output = "S"
		elif scissors < papers:
			output = "R"
		else:
			output = random.choice(["R", "P", "S"])
	elif rocks < scissors:
		if rocks < papers:
			output = "P"
		elif papers < rocks:
			output = "S"
		else:
			output = random.choice(["R", "P", "S"])
else:
	output = random.choice(["R", "P", "S"])