maybe?

Authorizzy+nch
Submission date2017-12-08 17:33:31.914920
Rating2782
Matches played316
Win rate24.05

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

Source code:

import random

# comment this out when submitting
#moves = "PPPSSSSRR"
#input = "P"


if input=="":
	moves=""
	

	def count_substring(str,sub):
                count_substring=0
		for i in range(len(str)):
			if str[i:i+len(sub)]==sub:
				count_substring+=1
			
		return count_substring
		




	def predictPatterns():
		rockCount=0
		paperCount=0
		scissorsCount=0
		last4=moves[-4:]
		last3=moves[-3:]
		last2=moves[-2:]

		# weight longer patterns more than shorter patterns, we did this by multiplyng by 5
		rockCount=count_substring(moves, last4+"R") * 5 + count_substring(moves, last3+"R") * 3 + count_substring(moves, last2+"R") 
		scissorsCount=count_substring(moves, last4+"S") * 5 + count_substring(moves, last3+"S") * 3 + count_substring(moves, last2+"S")
		paperCount=count_substring(moves, last4+"P") * 5 + count_substring(moves, last3+"P") * 3 + count_substring(moves, last2+"P")

	    # find the most likely outcome in order to counter it
		if rockCount > scissorsCount and rockCount > paperCount: 
			output = "P"
		elif scissorsCount > rockCount and scissorsCount > paperCount:
			output = "R"
		elif paperCount > rockCount and paperCount > scissorsCount:
			output = "S"
		else:
			output = random.choice(["R", "S", "P"])

		return output

moves=moves+input

# Pick random moves until we've seen enough to make predictions
if len(moves) < 500:
	output = random.choice(["R", "S", "P"])
else:
	predictPatterns()