&&&&

Author&&&
Submission date2011-06-20 19:11:30.881048
Rating6042
Matches played4966
Win rate61.52

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

Source code:

import random
#Weighted random beat previous inputs
def weighted_choice(C, p):
    x = random.random()
    for elmt in range(len(C)):
        if x <= p[elmt]:
            return C[elmt]
        x -= p[elmt]

if not input:
	beat={'R':'P','P':'S','S':'R','':'R'}
	output=random.choice("RPS")
	history=""
else:
	history+=input
	L=len(history)
	p = q = range(1,L+1)
	q=float(sum(q))
	for i in range(L):
		p[i]/=q
	output=beat[weighted_choice(history,p)]