def get_barriers(self): """ Return the list of barriers Points.""" points = set() points.update( self._find_all(Element('MEATCHOPPER'), Element('WALL'), Element('WALL_DESTROYABLE'), Element('OTHER_BOMBERMAN'), Element('OTHER_BOMB_BOMBERMAN'), Element('BOMB_TIMER_1'), Element('BOMB_TIMER_2'), Element('BOMB_TIMER_3'), Element('BOMB_TIMER_4'), Element('BOMB_TIMER_5'))) return list(points)
def get_the_nearest_bomberman(self): all_bombermen = self._find_all(Element('OTHER_BOMBERMAN')) my_point = self.get_bomberman() mx, my = my_point.get_x(), my_point.get_y() print(mx, my) d = {} for i in all_bombermen: x, y = i.get_x(), i.get_y() d[i] = int(sqrt((mx - x) ** 2 + (my - y) ** 2)) return min(d, key=d.get)
def get_bombs(self): """ Return the list of bombs Points.""" points = set() points.update( self._find_all(Element('BOMB_BOMBERMAN'), Element('BOMB_TIMER_1'), Element('BOMB_TIMER_2'), Element('BOMB_TIMER_5'), Element('BOMB_TIMER_4'), Element('BOMB_TIMER_3'))) return list(points)
def get_element_at(self, point): """ Return an Element object at coordinates x,y.""" return Element(self._string[self._xy2strpos(point.get_x(), point.get_y())])
def get_blasts(self): return self._find_all(Element('BOOM'))
def get_metchoppers(self): return self._find_all(Element('MEATCHOPPER'))
def get_destroyable_walls(self): return self._find_all(Element('WALL_DESTROYABLE'))
def am_i_dead(self): return self.find_first_element(Element('DEAD_BOMBERMAN')) is not None
def get_walls(self): return self._find_all(Element('WALL'))
def get_other_bombermans(self): return self._find_all(Element('OTHER_BOMBERMAN'), Element('OTHER_DEAD_BOMBERMAN'), Element('OTHER_BOMB_BOMBERMAN'))
def get_bomberman(self): return self.find_first_element(Element('BOMBERMAN'), Element('DEAD_BOMBERMAN'), Element('BOMB_BOMBERMAN'))
def get_fast_bombs(self, ind=2): """ Return the list of bombs Points.""" points = set() el = [Element('BOMB_TIMER_{}'.format(i)) for i in range(1, ind)] points.update(self._find_all(*el)) return list(points)
def is_free(self, point): if point.is_out_of_board(self._size): return False if self._find_all(Element('NONE'), Element('DEAD_MEATCHOPPER'), Element('OTHER_DEAD_BOMBERMAN')).__contains__(point): return True return False
def am_i_dead(self): return self._find_first(Element('DEAD_BOMBERMAN')).__contains__( element('DEAD_BOMBERMAN'))