当前位置: 首页>>代码示例>>Python>>正文


Python MilitaryAI.get_my_defense_rating_in_system方法代码示例

本文整理汇总了Python中MilitaryAI.get_my_defense_rating_in_system方法的典型用法代码示例。如果您正苦于以下问题:Python MilitaryAI.get_my_defense_rating_in_system方法的具体用法?Python MilitaryAI.get_my_defense_rating_in_system怎么用?Python MilitaryAI.get_my_defense_rating_in_system使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MilitaryAI的用法示例。


在下文中一共展示了MilitaryAI.get_my_defense_rating_in_system方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _portion_of_fleet_needed_here

# 需要导入模块: import MilitaryAI [as 别名]
# 或者: from MilitaryAI import get_my_defense_rating_in_system [as 别名]
    def _portion_of_fleet_needed_here(self):
        """Calculate the portion of the fleet needed in target system considering enemy forces."""
        # TODO check rating against planets
        if assertion_fails(self.type in COMBAT_MISSION_TYPES, msg=str(self)):
            return 0
        if assertion_fails(self.target and self.target.id != INVALID_ID, msg=str(self)):
            return 0
        system_id = self.target.id
        aistate = get_aistate()
        local_defenses = MilitaryAI.get_my_defense_rating_in_system(system_id)
        potential_threat = CombatRatingsAI.combine_ratings(
            MilitaryAI.get_system_local_threat(system_id),
            MilitaryAI.get_system_neighbor_threat(system_id)
        )
        universe = fo.getUniverse()
        system = universe.getSystem(system_id)

        # tally planetary defenses
        total_defense = total_shields = 0
        for planet_id in system.planetIDs:
            planet = universe.getPlanet(planet_id)
            total_defense += planet.currentMeterValue(fo.meterType.defense)
            total_shields += planet.currentMeterValue(fo.meterType.shield)
        planetary_ratings = total_defense * (total_shields + total_defense)
        potential_threat += planetary_ratings  # TODO: rewrite to return min rating vs planets as well

        # consider safety factor just once here rather than everywhere below
        safety_factor = aistate.character.military_safety_factor()
        potential_threat *= safety_factor

        fleet_rating = CombatRatingsAI.get_fleet_rating(self.fleet.id)
        return CombatRatingsAI.rating_needed(potential_threat, local_defenses) / float(fleet_rating)
开发者ID:adrianbroher,项目名称:freeorion,代码行数:34,代码来源:AIFleetMission.py


注:本文中的MilitaryAI.get_my_defense_rating_in_system方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。