random_boy_v2

Authorzanzaaa
Submission date2017-12-08 17:55:20.055400
Rating5895
Matches played304
Win rate54.28

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

Source code:

#program is a simplified version of the derp_v6 program added with the novice new york times program
import random
if input == "":		
	comp_wins = 0
	win = ['RP', 'PS', 'SR']
	comp_move = ''
	input_prediction = ''
	x = 0
	randumb = 1
	strats = 1
	opponents_moves = ''
	if input == 'R':
		opponents_moves + 'R'
	elif input == 'P': 
		opponents_moves + 'P'
	else:
		opponents_moves + 'S'
	last5 = opponents_moves[-5:]
	def count_substring(STR, SUB):
		count = 0
		for i in range(len(STR)-1):
			if SUB[i:i+1] == 'R' or 'P' or 'S':
				count += 1
		return count
	countP = count_substring(opponents_moves, last5 + 'P')
	countR = count_substring(opponents_moves, last5 + 'R')
	countS = count_substring(opponents_moves, last5 + 'S')

else:
	x += 1
	if countP > countR and countP > countS:
			input_prediction = 'S'
	elif countS > countR:
			input_prediction = 'R'
	else:
			input_prediction = 'P'
	
	if (input+output) in win:
		comp_wins +=1 
	if input_prediction == input:
		strats += 1
	else:
		randumb += 1
	if input == 'R':
		opponents_moves + 'R'
	elif input == 'P': 
		opponents_moves + 'P'
	else:
		opponents_moves + 'S'
	randumb *= 0.97
	strats *= 0.97
	
if x >=5: 
	if random.random() < strats/(strats+randumb):
		if countP > countR and countP > countS:
			output = 'S'
		elif countS > countR:
			output = 'R'
		else:
			output = 'P'

	elif random.random() > strats/(strats+randumb):
		if random.random() > comp_wins/(comp_wins-strats) > strats/(strats+randumb):
			output = 'R'
		elif random.random() < comp_wins/(comp_wins-strats):
			output = 'P'
		else:
			output = 'S'

if x > 500 and comp_wins < 100:
	output = random.choice(['R','P','S'])

else:
	output = random.choice(['R','P','S'])