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


Python InvasionAI.assignInvasionValues方法代码示例

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


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

示例1: check_retarget_invasion

# 需要导入模块: import InvasionAI [as 别名]
# 或者: from InvasionAI import assignInvasionValues [as 别名]
 def check_retarget_invasion(self):
     "checks if an invasion mission should be retargeted"
     universe=fo.getUniverse()
     empire = fo.getEmpire()
     empire_id = fo.empireID()
     fleet_id = self.target_id
     fleet=universe.getFleet(fleet_id)
     if fleet.systemID == -1:
         #next_loc=fleet.nextSystemID
         return #TODO: still check
     system = universe.getSystem(fleet.systemID)
     if not system:
         return
     orders=self.getAIFleetOrders()
     last_sys_target = -1
     if orders:
         last_sys_target = orders[-1].getTargetAITarget().target_id
     if last_sys_target == fleet.systemID:
         return #TODO: check for best local target
     open_targets = []
     already_targeted = InvasionAI.getInvasionTargetedPlanetIDs(system.planetIDs, EnumsAI.AIFleetMissionType.FLEET_MISSION_INVASION, empire_id)
     for pid in system.planetIDs:
         if pid in already_targeted or (pid in foAI.foAIstate.qualifyingTroopBaseTargets):
             continue
         planet = universe.getPlanet(pid)
         if planet.unowned or (planet.owner == empire_id):
             continue
         if  (planet.currentMeterValue(fo.meterType.shield)) <= 0:
             open_targets.append(pid)
     if not open_targets:
         return
     troop_pod_tally = FleetUtilsAI.countPartsFleetwide(fleet_id, ["GT_TROOP_POD"])
     targetID=-1
     bestScore=-1
     target_troops = 0
     #
     fleetSupplyableSystemIDs = empire.fleetSupplyableSystemIDs
     fleetSupplyablePlanetIDs = PlanetUtilsAI.getPlanetsInSystemsIDs(fleetSupplyableSystemIDs)
     for pid,  rating in InvasionAI.assignInvasionValues(open_targets, EnumsAI.AIFleetMissionType.FLEET_MISSION_INVASION, fleetSupplyablePlanetIDs, empire).items():
         p_score,  p_troops = rating
         if p_score>bestScore:
             if p_troops >= 2*troop_pod_tally:
                 continue
             bestScore = p_score
             targetID = pid
             target_troops = p_troops
     if targetID == -1:
         return
     
     newFleets=FleetUtilsAI.splitFleet(fleet_id)
     self.clearAITargets(-1)#TODO: clear from foAIstate
     self.clearAIFleetOrders()
     podsNeeded= max(0,  math.ceil( (target_troops - 2*(FleetUtilsAI.countPartsFleetwide(fleet_id, ["GT_TROOP_POD"]))+0.05)/2.0) )
     foundStats={}
     minStats= {'rating':0, 'troopPods':podsNeeded}
     targetStats={'rating':10,'troopPods':podsNeeded}
     foundFleets = []
     theseFleets = FleetUtilsAI.getFleetsForMission(1, targetStats , minStats,   foundStats,  "",  systemsToCheck=[fleet.systemID],  systemsChecked=[], fleetPoolSet=set(newFleets),   fleetList=foundFleets,  verbose=False)
     for fid2 in foundFleets:
         FleetUtilsAI.mergeFleetAintoB(fid2,  fleet_id)
     aiTarget = AITarget.AITarget(EnumsAI.AITargetType.TARGET_PLANET, targetID)
     self.addAITarget(EnumsAI.AIFleetMissionType.FLEET_MISSION_INVASION, aiTarget)
     self.generateAIFleetOrders()
开发者ID:e-h-j,项目名称:freeorion,代码行数:65,代码来源:AIFleetMission.py


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