Deepfreq

AuthorFreqAuthor
Submission date2019-01-12 03:46:08.351771
Rating5847
Matches played200
Win rate58.5

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

Source code:

from collections import defaultdict
import random

D = 3

if input == "":
	output = random.choice("RPS")
	my = output
	their = ""
	allcounts = defaultdict(lambda: defaultdict(int))
else:
	their += input
	if len(their) >= D+1:
		hist = ''.join(''.join(x) for x in zip(my, their))
		allcounts[hist[-2*(D+1):-2]][hist[-1]] += 1
		counts = allcounts[hist[-2*D:]]
		if counts["R"] > counts["P"] and counts["R"] > counts["S"]:
			output = "P"
		elif counts["P"] > counts["S"]:
			output = "S"
		else:
			output = "R"
	else:
		output = random.choice("RPS")
	my += output