PBWinrate

AuthorAntiDog
Submission date2018-08-08 12:20:55.475640
Rating4298
Matches played294
Win rate45.24

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

Source code:

import random
#pick_by_winrate
output = ""
if input == "":
	output = "P"
	oponentmoves = ""
	wins = {"R":0, "P":0, "S":0}
else:
	oponentmoves += input
	def beats(x,y):
		if x == "R":
			if y == "S": return True
		if x == "P":
			if y == "R": return True
		if x == "S":
			if y == "P": return True
		return False
	if last != "" and oponentmoves != "":
		if beats(last, oponentmoves[-1]):
			if lastIn+last in wins:
				wins[lastIn+last] += 1
			else:
				wins[lastIn+last] = 1
		if beats(oponentmoves[-1], last):
			if lastIn+last in wins:
				wins[lastIn+last] -= 1
			else:
				wins[lastIn+last] = -1
		r = 0
		p = 0
		s = 0
		for w in wins:
			if len(w) >1 and w[0] == input:
				if w[1] == "R":
					r += 1
				if w[1] == "P":
					p += 1
				if w[1] == "S":
					s += 1
		if r > p and r > s:
			output = "P"
		elif p > s and p > r:
			output = "S"
		elif s > p and s > r:
			output = "R" 
if output == "":
	output = random.choice(["R","P","S"])
lastIn = input
last = output