This program has been disqualified.
Author | Dhaivat Pandya |
Submission date | 2011-08-08 06:54:03.085415 |
Rating | 2807 |
Matches played | 768 |
Win rate | 26.95 |
import random
#Weighted random beat previous inputs
KEY=0.990
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':'P','S':'R','':'R'}
output=random.choice("RPS")
history=""
AMPERSAND_SECRET_SAUCE = "SSPPRSPSPRPRPPSRRSRPPSRSRSSSSSSPPPPSRPRSRPSPRPSPRR"
else:
history+=input
L=len(history)
if AMPERSAND_SECRET_SAUCE in history:
output = 'S'
else:
p = q = range(1,L+1)
for i in range(L):
p[i]=p[i]**(KEY)
q[i]=q[i]**(KEY)
q=float(sum(q))
for i in range(L):
p[i]/=q
output=beat[weighted_choice(history,p)]