Ejemplo n.º 1
0
 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 Sprite.is_movable_terrain(
                 self,
                 move_to_tile) and self.not_contains_sprite(move_to_tile):
             Sprite.move(self, move_to_tile)
         else:
             Sprite.move(self)
     elif target_tile:
         move_to_tile = vision.approach(self.tile, target_tile,
                                        self.world_map)
         if Sprite.is_movable_terrain(
                 self, move_to_tile) and Sprite.not_contains_sprite(
                     self, move_to_tile, self.prey):
             if move_to_tile == target_tile:
                 move_to_tile.contains_sprite.die()
             Sprite.move(self, move_to_tile)
         else:
             Sprite.move(self)
     else:
         Sprite.move(self)
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
 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)
Ejemplo n.º 4
0
 def move(self, target=None):
     visible_tiles = vision.vision(15, self.world_map, self.tile)
     visible_tiles = filter(BeesSprite.pollinated_filter, visible_tiles)
     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 Sprite.is_movable_terrain(self, move_to_tile) and \
                 Sprite.not_contains_sprite(self, move_to_tile, self.prey):
             if move_to_tile == target_tile:
                 move_to_tile.contains_sprite.pollinate()
             Sprite.move(self, move_to_tile)
         else:
             Sprite.move(self)
     else:
         Sprite.move(self)
Ejemplo n.º 5
0
 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)