Triplefreq

AuthorFreqAuthor
Submission date2019-01-12 01:24:07.418550
Rating6104
Matches played253
Win rate60.08

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

Source code:

from collections import defaultdict
import random

if input == "":
	output = random.choice("RPS")
	my = output
	their = ""
	allcounts = defaultdict(lambda: defaultdict(int))
else:
	their += input
	if len(their) >= 3:
		allcounts[my[-3]+their[-3]+my[-2]+their[-2]][their[-1]] += 1
		counts = allcounts[my[-2]+their[-2]+my[-1]+their[-1]]
		if counts["R"] > counts["P"] and counts["R"] > counts["S"]:
			output = "P"
		elif counts["P"] > counts["S"]:
			output = "S"
		else:
			output = "R"
	else:
		output = "PSR"[["R", "P", "S"].index(input)]
	my += output