pick_by_winrate_penalty4

AuthorAntiDog
Submission date2018-08-08 13:40:35.100450
Rating4146
Matches played215
Win rate40.93

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

Source code:

import random
#pick_by_winrate
if input == "":
	output = "P"
	oponentmoves = ""
	wins = {"RR":2, "RP":2, "RS":-1}
	lastOut= ""
else:
	def beats(x,y):
		if x == "R" and y == "S": return True
		if x == "P" and y == "R": return True
		if x == "S" and y == "P": return True
		return False
	best_wr = 0
	best_output = random.choice(["R","P","S"])
	if input != "" and lastOut != "":
		id = input+lastOut
		if beats(lastOut, input):
			if id in wins:
				wins[id] = wins[id] + 1
			else:
				wins[id] = 1.0
		elif beats(input, lastOut):
			if id in wins:
				wins[id] = wins[id] - 1
			else:
				wins[id] = -1.0
		for w in wins:
			if w[0] == input and wins[w] > best_wr:
				best_wr = wins[w]
				best_output = w[1]
	output = best_output
lastOut = output
print output