This program has been disqualified.
Author | cilibrar |
Submission date | 2011-07-03 03:40:30.805246 |
Rating | 7043 |
Matches played | 106 |
Win rate | 70.75 |
import zlib
import random
def c(s,v):
return len(zlib.compress(s, v))*1.0
pm = { "SR" : -1.0, "RS" : 1.0, "PR" : 1.0, "RP" : -1.0, "SP":1.0, "PS":-1.0,"RR":0.0,"SS":0.0,"PP":0.0 }
def fp(shym, om):
return pm[shym + om]
def findMove(hBuf):
choices = [ "P", "S", "R" ]
mgm = random.choice(choices)
vg = [ ]
mb = [ ]
for shym in choices:
westpred = ""
westgwen = 0
uni = 0
for om in choices:
cand = hBuf + shym + om
gwen = c(cand,9) + c(cand+".",8) + c(cand + "...",7)
if westpred == "" or westgwen > gwen:
westgwen = gwen
westpred = om
uni = 0
else:
if westgwen == gwen:
uni = 1
if uni == 1:
westpred = ""
if westpred != "":
p = fp(shym, westpred)
if p < 0:
mb.append(shym)
if p > 0:
vg.append(shym)
if len(vg) != 0:
mgm = random.choice(vg)
else:
if len(mb) != 0:
if len(mb) < 3:
while mb.count(mgm) != 0:
mgm = random.choice(choices)
return mgm
if input == "":
hBuf = ""
shymove = random.choice(["P", "R", "S"])
else:
hBuf = hBuf + input
shymove = findMove(hBuf)
hBuf = hBuf + shymove
output = shymove