def fighting_ships_in_sight(self, **environment):
        """
		Attacks frigates only if they are enemies already and the power balance is advantageous.
		"""
        enemies = environment['enemies']
        ship_group = environment['ship_group']
        power_balance = environment['power_balance']

        if power_balance < self.power_balance_threshold:
            BehaviorComponent.log.info('%s: Enemy group is too strong',
                                       self.__class__.__name__)
            return

        # attack ship with the lowest HP
        target_ship = UnitManager.get_lowest_hp_ship(enemies)

        if self.session.world.diplomacy.are_enemies(self.owner,
                                                    target_ship.owner):
            for ship in ship_group:
                ship.attack(target_ship)
            BehaviorComponent.log.info('%s: Attacked enemy ship',
                                       self.__class__.__name__)
        else:
            BehaviorComponent.log.info('%s: Enemy ship was not hostile',
                                       self.__class__.__name__)
Ejemplo n.º 2
0
	def fighting_ships_in_sight(self, **environment):
		"""
		Attacks frigates only if they are enemies. Does not care about power balance.
		"""

		enemies = environment['enemies']
		ship_group = environment['ship_group']

		if not self.session.world.diplomacy.are_enemies(self.owner, enemies[0].owner):
			BehaviorComponent.log.info('%s: Enemy ship was not hostile', self.__class__.__name__)
			return

		target_ship = UnitManager.get_lowest_hp_ship(enemies)
		for ship in ship_group:
			ship.attack(target_ship)
		BehaviorComponent.log.info('%s: Attacked enemy ship', self.__class__.__name__)
Ejemplo n.º 3
0
	def fighting_ships_in_sight(self, **environment):
		"""
		Attacks frigates only if they are enemies. Does not care about power balance.
		"""

		enemies = environment['enemies']
		ship_group = environment['ship_group']

		if not self.session.world.diplomacy.are_enemies(self.owner, enemies[0].owner):
			BehaviorComponent.log.info('%s: Enemy ship was not hostile', self.__class__.__name__)
			return

		target_ship = UnitManager.get_lowest_hp_ship(enemies)
		for ship in ship_group:
			ship.attack(target_ship)
		BehaviorComponent.log.info('%s: Attacked enemy ship', self.__class__.__name__)
Ejemplo n.º 4
0
	def fighting_ships_in_sight(self, **environment):
		"""
		Attacks frigates only if they are enemies already and the power balance is advantageous.
		"""
		enemies = environment['enemies']
		ship_group = environment['ship_group']
		power_balance = environment['power_balance']

		if power_balance < self.power_balance_threshold:
			BehaviorComponent.log.info('%s: Enemy group is too strong', self.__class__.__name__)
			return

		# attack ship with the lowest HP
		target_ship = UnitManager.get_lowest_hp_ship(enemies)

		if self.session.world.diplomacy.are_enemies(self.owner, target_ship.owner):
			for ship in ship_group:
				ship.attack(target_ship)
			BehaviorComponent.log.info('%s: Attacked enemy ship', self.__class__.__name__)
		else:
			BehaviorComponent.log.info('%s: Enemy ship was not hostile', self.__class__.__name__)