def act_piece(self): if do_debug: call(self.__class__.__name__) situation = self.info.situation piece = self.info.piece location = piece.get_location() depth = situation.piece_types[piece.piece_type_id].speed * 10 criteria = lambda x: situation.is_tile_free_city(x) result = algos.breadth_first_piece_search(location, depth, situation, piece, criteria) if result is None: return self.FAILURE else: piece.path = result del piece.path[0] piece.destination = result[-1] return self.SUCCESS
def act_piece(self): piece = self.info.piece situation = self.info.situation continent = self.info.continent group = continent.get_group(self.info.piece.target) def criteria(a): locations = [algos.add_locations(a, b) for b in algos.directions] tests = [ situation.is_in_map(b) and continent.get_group(b) == group for b in locations ] return any(tests) depth = situation.width * situation.height piece.path = algos.breadth_first_piece_search(piece.get_location(), depth, situation, piece, criteria) if piece.path is None: return self.FAILURE del piece.path[0] return self.SUCCESS