RPS BruteForcePredict

AuthorAntiDog
Submission date2018-08-07 14:14:16.974670
Rating3792
Matches played275
Win rate34.18

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

Source code:

import time
if input == "":
	future = time.time()+ 4.5
	output = "P"
	oponentmoves = ""
else:
	oponentmoves += input
	r = 0
	p = 0
	s = 0
	for i in range(1,len(oponentmoves)):
		if time.time() > future:
			break
		searchsequence = oponentmoves[len(oponentmoves)-i:]
		nextresults = oponentmoves.split(searchsequence)
		k = 0
		for res in nextresults:
			if time.time() > future:
				break
			n = 1
			k+=1
			if k == 1:
				continue
			if res == "": 
				res = searchsequence
				n = len(",".join(oponentmoves.split(searchsequence)))
			if res[0] == "R":
				r += n
			elif res[0] == "P":
				p += n
			elif res[0] == "S":
				s += n
			else:
				continue
	if r >= p and r >= s:
		output = "P" #plays R
	elif p >= s and p >= r:
		output = "S" #plays P
	else:
		output = "R" #plays S