def move(self): if self.destination == geometry.adjacent(self.position,self.direction): self.position = geometry.adjacent(self.position,self.direction) self.exhaustion += 1 #self.purpose() self.trail.insert(0,self.position) self.trail.pop()
def draw(self,draw_api,astep=0,off=(0,0),rot=0): if self.position != self.destination: (ia,ja) = self.position (ib,jb) = geometry.adjacent(self.position,self.direction) (io,jo) = off offsum = (io+(ib-ia)*astep,jo+(jb-ja)*astep) else: offsum = off draw_api.highlight_hexagon(self.position,self.color,off=offsum,rot=rot)
def purpose(self): if self.exhaustion > 3: self.destination = self.position #self.turn_left() self.exhaustion -= 1 else: if self.direction == self.intent: self.destination = geometry.adjacent(self.position,self.direction) else: self.destination = self.position if self.intent is not None: if self.direction > self.intent: self.turn_right() if self.direction < self.intent: self.turn_left()
def set_purpose(arctic, list_of_bears): for b in list_of_bears[1:]: a = [0] * 6 # adjacent hexes c = 0 # current position a[b.direction + 2] = 1 for o in list_of_bears: if o.identity != b.identity: for i in range(6): a[i] += evaluate_hex_on_bear_position( geometry.adjacent(b.position, i % 6 - 2), o.position) c += evaluate_hex_on_bear_position(b.position, o.position) amax = max(a) #print(b.intent) if amax > c: #print(a.index(amax)%6-2) b.intent = a.index(amax) % 6 - 2 else: b.intent = None b.purpose()
def shift_forward(self): self.position = geometry.adjacent(self.position,3) self.destination = geometry.adjacent(self.destination,3) for k in range(TRAILLENGTH): self.trail[k] = geometry.adjacent(self.trail[k],3)