sicilian.v1

Authorcuriouscat
Submission date2012-12-21 15:41:06.827551
Rating4585
Matches played729
Win rate47.87

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

Source code:

import random
def most_common(l):
    max = 0
    maxitem = None
    for x in set(l):
        count =  l.count(x)
        if count > max:
            max = count
            maxitem = x
    return maxitem
#################################
if input == "": # initialize variables for the first round
    output=random.choice(['R','P','S'])
    round=0
    strategy=[0.3,0.6,0.9]
    used=[0,0,0]
    result={'RR':0,'PP':0,'SS':0,'RP':-1,'RS':1,'PR':+1,'PS':-1,'SR':-1,'SP':+1}
else: 
	if round >1 :
	   str=output+input
	   val=result[str]
	   strategy[last_str]+=val

	max_value = max(strategy)
	max_index = strategy.index(max_value)

	if max_index==0:
	    response = {'R': 'R', 'P': 'P','S' : 'S'}
            output=response[input]
            used[0]+=1
	    last_str=0
	elif max_index==1:
	    response = {'R': 'P', 'P': 'S','S' : 'R'}
            output=response[input]
            used[1]+=1
	    last_str=1
	else:
	    response = {'R': 'S', 'P': 'R','S' : 'P'}
            output=response[input]
            used[2]+=1
	    last_str = 2
    
	round+=1