pick_by_winrate

AuthorAntiDog
Submission date2018-08-08 13:11:22.597550
Rating4941
Matches played276
Win rate47.1

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
				
		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