Badly Weighted7

AuthorAntiDog
Submission date2018-08-08 11:35:45.010130
Rating3364
Matches played260
Win rate32.31

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

Source code:

import random
if input == "":
	output = "P"
	oponentmoves = ""
else:
	oponentmoves += input
	if(len(oponentmoves) > 25):
		oponentmoves = oponentmoves[:25]
	r = 0.0
	p = 0.0
	s = 0.0
	for j in range(2, 4):
		for i in range(1,len(oponentmoves)-j):
			cr = 0.0
			cp = 0.0
			cs = 0.0
			searchsequence = oponentmoves[i:i+j]
			if(searchsequence[-1] != oponentmoves[-1]):
				continue
			nextresults = oponentmoves.split(searchsequence)
			k = 0
			weight = 1.0
			for res in nextresults:
				n = 1
				k+=1
				weight = 1#(len(oponentmoves))/float(max(len(res),0.99))
				if k == 1:
					continue
				if res == "": 
					res = searchsequence
					n = len(",".join(oponentmoves.split(searchsequence)[1:]))
				if res[0] == "R":
					cr += n *weight
				elif res[0] == "P":
					cp += n *weight
				elif res[0] == "S":
					cs += n *weight
				else:
					continue
			ct = cr+cp+cs
			r += cr/ct if ct > 0 else 0
			p += cp/ct if ct > 0 else 0
			s += cs/ct if ct > 0 else 0

	ct = r+p+s
	r_chance = r/ct if ct > 0 else 0
	p_chance = p/ct if ct > 0 else 0
	s_chance = s/ct if ct > 0 else 0
	if r_chance > p_chance and r_chance > s_chance:
		output = "P"
		next = "R"
	elif p_chance > s_chance and p_chance > r_chance:
		output = "S"
		next = "P"
	elif s_chance > p_chance and s_chance > r_chance:
		output = "R" 
		next = "S"
	else:
		output = random.choice(["R","P","S"])