random2

Authorjiaw
Submission date2011-09-10 21:49:23.963805
Rating4724
Matches played2603
Win rate47.71

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

Source code:

import random
#test = random.choice(["R","P","S"])
#output = test
#total = 1000
#counter = 0
#bucket = []
#RC = PC = SC = 0

if input == "": # initialize variables for the first round
	RC = PC = SC = 0
	counter = 0
	
elif input == "R":
	RC+= 1
        counter += 1
elif input == "P":
	PC += 1
        counter += 1
elif input == "S":
	SC += 1
        counter += 1
if counter <= 10:
	test = random.choice(["R","P","S"])
	output = test
else:
	if RC > PC and RC > SC:
		output = "P" # paper beats rock
		RC -= 1
	elif PC > SC and PC > RC:
		output = "S" # scissors beats paper	
		PC -= 1
	else:
		output = "R" # rock beats scissors
		SC -= 1