nch1

Authornch
Submission date2017-12-07 05:40:39.607080
Rating4992
Matches played304
Win rate50.33

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

Source code:

import random

if input=="":
	moves=""
moves=moves+input

def count_substring(str, sub):
	if len(str)==0:
		return 0
	if str[0:len(sub)]==(sub):
		return 1 + count_substring(str[1:], sub)
	else:
		return 0+count_substring(str[1:], sub)

def predictPatterns():

	rockCount=0
	paperCount=0
	scissorsCount=0
	last4=moves[-4:]
	last3=moves[-3:]
	last2=moves[-2:]
	#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")


	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

if len(moves) < 50:
	output = random.choice(["R", "S", "P"])
else:
	output = predictPatterns()