def spawn(self): """ @Override :return: """ AnimalSprite.spawn(self) self.tile.ignore_contents = True
def move(self, target=None): visible_tiles = vision.vision(4, self.world_map, self.tile) flight_tile = vision.find_target(visible_tiles, self.predators) target_tile = vision.find_target(visible_tiles, self.prey) if flight_tile: move_to_tile = vision.flee(self.tile, flight_tile, self.world_map) if self.is_movable_terrain(move_to_tile) and self.not_contains_sprite(move_to_tile): AnimalSprite.move(self, move_to_tile) else: AnimalSprite.move(self) elif target_tile: move_to_tile = vision.approach(self.tile, target_tile, self.world_map) if self.is_movable_terrain(move_to_tile) and self.not_contains_sprite(move_to_tile, self.prey): if move_to_tile == target_tile: move_to_tile.contains_sprite.die() AnimalSprite.move(self, move_to_tile) else: AnimalSprite.move(self) else: AnimalSprite.move(self)
def move(self): """ :return: """ visible_tiles = vision.vision(4, self.world_map, self.tile) target_tile = vision.find_target(visible_tiles, self.prey) if target_tile: move_to_tile = vision.approach(self.tile, target_tile, self.world_map) if self.is_movable_terrain(move_to_tile) and self.not_contains_sprite(move_to_tile, self.prey): AnimalSprite.move(self, move_to_tile) else: AnimalSprite.move(self) else: AnimalSprite.move(self)
def move(self, target=None): """ @Override Move sprite to a specified target tile (target). Otherwise, moves sprite to a random adjacent tile. :param target: Target tile to move sprite. """ visible_tiles = vision.vision(self.vision, self.world_map, self.tile) target_tile = vision.find_target(visible_tiles, self.prey) if target_tile: move_to_tile = vision.approach(self.tile, target_tile, self.world_map) if self.is_movable_terrain( move_to_tile) and self.not_contains_sprite( move_to_tile, self.prey): if move_to_tile == target_tile: move_to_tile.contains_sprite.die() AnimalSprite.move(self, move_to_tile) else: AnimalSprite.move(self) else: AnimalSprite.move(self)
def move(self, target=None): """ :return: """ visible_tiles = vision.vision(10, self.world_map, self.tile) target_tile = vision.find_target(visible_tiles, self.prey) if target_tile: move_to_tile = vision.approach(self.tile, target_tile, self.world_map) if self.is_movable_terrain( move_to_tile) and self.not_contains_sprite( move_to_tile, self.prey): if move_to_tile == target_tile: move_to_tile.contains_sprite.die() AnimalSprite.move(self, move_to_tile) elif not self.is_leader: leader_tile = self.find_leader() if leader_tile: move_to_tile = vision.approach(self.tile, leader_tile, self.world_map) if self.is_movable_terrain( move_to_tile) and self.not_contains_sprite( move_to_tile, self.prey): AnimalSprite.move(self, move_to_tile) else: AnimalSprite.move(self) else: AnimalSprite.move(self) elif not self.is_leader: leader_tile = self.find_leader() if leader_tile: chance = random.randint(0, 10) if chance == 0: AnimalSprite.move(self) else: move_to_tile = vision.approach(self.tile, leader_tile, self.world_map) if self.is_movable_terrain( move_to_tile) and self.not_contains_sprite( move_to_tile, self.prey): AnimalSprite.move(self, move_to_tile) else: AnimalSprite.move(self) else: AnimalSprite.move(self)