pick_by_winrate_penalty

AuthorAntiDog
Submission date2018-08-08 13:15:45.308940
Rating4650
Matches played274
Win rate43.8

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

Source code:

import random
#pick_by_winrate
output = ""
if input == "":
	output = "P"
	oponentmoves = ""
	lastIn = "P"
	input = "s"
	wins = {}
else:
	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 lastIn != "" and lastOut != "":
		if beats(lastOut, lastIn):
			id = ""+lastIn+lastOut
			if id in wins:
				wins[id] = wins[id] + 1
			else:
				wins[id] = 1
		if beats(lastIn, lastOut):
			id = ""+lastIn+lastOut
			if id in wins:
				wins[id] = wins[id] - 1
			else:
				wins[id] = -1
		best_wr = 0
		output = random.choice(["R","P","S"])
		for w in wins:
			if len(w) < 2:
				continue
			if w[0] == input and wins[w] > best_wr:
				best_wr = wins[w]
				output = w[1]
lastIn = input
lastOut = output