#Rebel
This bot combines the simple strategy of Hesitate
with the advanced last round strategy of BotFor2X
,
tries to remember who it is and goes wild when it finds
it lives in an illusion.
class Rebel(Bot):
p = []
def __init__(self,*args):
super().__init__(*args)
self.hide_from_harkonnen=self.make_throw
if self.p:
return
l = [0]*5+[1]
for i in range(300):
l.append(sum(l[i:])/6)
m=[i/6 for i in range(1,5)]
self.p.extend((1-sum([a*b for a,b in zip(m,l[i:])])
for i in range(300) ))
def update_state(self,*args):
super().update_state(*args)
self.current_sum = sum(self.current_throws)
# remember who we are:
self.make_throw=self.hide_from_harkonnen
def expect(self,mts,ops):
p = 1
for s in ops:
p *= self.p[mts-s]
return p
def throw_again(self,mts,ops):
ps = self.expect(mts,ops)
pr = sum((self.expect(mts+d,ops) for d in range(1,6)))/6
return pr>ps
def make_throw(self, scores, last_round):
myscore = scores[self.index]
if len(self.current_throws)>1:
# hello Tleilaxu!
target = 666
elif last_round:
target = max(scores)
elif myscore==0:
target = 17
else:
target = 35
while myscore+self.current_sum < target:
yield True
if myscore+self.current_sum < 40:
yield False
opscores = scores[self.index+1:] + scores[:self.index]
for i in range(len(opscores)):
if opscores[i]>=40:
opscores = opscores[:i]
break
while True:
yield self.throw_again(myscore+self.current_sum,opscores)