本文整理汇总了Python中MoveUtilsAI.get_safe_path_leg_to_dest方法的典型用法代码示例。如果您正苦于以下问题:Python MoveUtilsAI.get_safe_path_leg_to_dest方法的具体用法?Python MoveUtilsAI.get_safe_path_leg_to_dest怎么用?Python MoveUtilsAI.get_safe_path_leg_to_dest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MoveUtilsAI
的用法示例。
在下文中一共展示了MoveUtilsAI.get_safe_path_leg_to_dest方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: issue_order
# 需要导入模块: import MoveUtilsAI [as 别名]
# 或者: from MoveUtilsAI import get_safe_path_leg_to_dest [as 别名]
def issue_order(self):
if not super(OrderResupply, self).issue_order():
return
fleet_id = self.fleet.id
system_id = self.target.get_system().id
fleet = self.fleet.get_object()
if system_id not in [fleet.systemID, fleet.nextSystemID]:
# if self.order_type == AIFleetOrderType.ORDER_MOVE:
# dest_id = system_id
# else:
# if self.order_type == AIFleetOrderType.ORDER_REPAIR:
# fo.issueAggressionOrder(fleet_id, False)
start_id = FleetUtilsAI.get_fleet_system(fleet)
dest_id = MoveUtilsAI.get_safe_path_leg_to_dest(fleet_id, start_id, system_id)
print "fleet %d with order type(%s) sent to safe leg dest %s and ultimate dest %s" % (
fleet_id, self.ORDER_NAME,
PlanetUtilsAI.sys_name_ids([dest_id]),
PlanetUtilsAI.sys_name_ids([system_id]))
fo.issueFleetMoveOrder(fleet_id, dest_id)
print "Order issued: %s fleet: %s target: %s" % (self.ORDER_NAME, self.fleet, self.target)
if system_id == fleet.systemID:
if foAI.foAIstate.get_fleet_role(fleet_id) == MissionType.EXPLORATION:
if system_id in foAI.foAIstate.needsEmergencyExploration:
foAI.foAIstate.needsEmergencyExploration.remove(system_id)
self.order_issued = True
示例2: issue_order
# 需要导入模块: import MoveUtilsAI [as 别名]
# 或者: from MoveUtilsAI import get_safe_path_leg_to_dest [as 别名]
def issue_order(self):
if not super(OrderResupply, self).issue_order():
return False
fleet_id = self.fleet.id
system_id = self.target.get_system().id
fleet = self.fleet.get_object()
if system_id == fleet.systemID:
if foAI.foAIstate.get_fleet_role(fleet_id) == MissionType.EXPLORATION:
if system_id in foAI.foAIstate.needsEmergencyExploration:
foAI.foAIstate.needsEmergencyExploration.remove(system_id)
return True
if system_id != fleet.nextSystemID:
self.executed = False
start_id = FleetUtilsAI.get_fleet_system(fleet)
dest_id = MoveUtilsAI.get_safe_path_leg_to_dest(fleet_id, start_id, system_id)
universe = fo.getUniverse()
print "fleet %d with order type(%s) sent to safe leg dest %s and ultimate dest %s" % (
fleet_id, self.ORDER_NAME, universe.getSystem(dest_id), universe.getSystem(system_id))
fo.issueFleetMoveOrder(fleet_id, dest_id)
print "Order issued: %s fleet: %s target: %s" % (self.ORDER_NAME, self.fleet, self.target)
return True
示例3: issue_order
# 需要导入模块: import MoveUtilsAI [as 别名]
# 或者: from MoveUtilsAI import get_safe_path_leg_to_dest [as 别名]
def issue_order(self):
if not super(OrderRepair, self).issue_order():
return
fleet_id = self.fleet.id
system_id = self.target.get_system().id
fleet = self.fleet.get_object()
if system_id not in [fleet.systemID, fleet.nextSystemID]:
fo.issueAggressionOrder(fleet_id, False)
start_id = [fleet.systemID, fleet.nextSystemID][fleet.systemID == INVALID_ID]
dest_id = MoveUtilsAI.get_safe_path_leg_to_dest(fleet_id, start_id, system_id)
print "fleet %d with order type(%s) sent to safe leg dest %s and ultimate dest %s" % (fleet_id, self.ORDER_NAME,
PlanetUtilsAI.sys_name_ids([dest_id]),
PlanetUtilsAI.sys_name_ids([system_id]))
fo.issueFleetMoveOrder(fleet_id, dest_id)
print "Order issued: %s fleet: %s target: %s" % (self.ORDER_NAME, self.fleet, self.target)
if system_id == fleet.systemID:
if foAI.foAIstate.get_fleet_role(fleet_id) == MissionType.EXPLORATION:
if system_id in foAI.foAIstate.needsEmergencyExploration:
del foAI.foAIstate.needsEmergencyExploration[foAI.foAIstate.needsEmergencyExploration.index(system_id)]
self.order_issued = True
示例4: issueOrder
# 需要导入模块: import MoveUtilsAI [as 别名]
# 或者: from MoveUtilsAI import get_safe_path_leg_to_dest [as 别名]
#.........这里部分代码省略.........
if shipID is None:
shipID = FleetUtilsAI.getShipIDWithRole(fleetID, AIShipRoleType.SHIP_ROLE_BASE_COLONISATION)
planetID = self.getTargetAITarget().target_id
planet=universe.getPlanet(planetID)
planetName = (planet and planet.name) or "apparently invisible"
result = fo.issueColonizeOrder(shipID, planetID)
print "Ordered colony ship ID %d to colonize %s, got result %d"%(shipID, planetName, result)
if result==0:
self.__executed = False
# invade
elif AIFleetOrderType.ORDER_INVADE == self.getAIFleetOrderType():
result = False
shipID = None
planetID = self.getTargetAITarget().target_id
planet=universe.getPlanet(planetID)
planetName = (planet and planet.name) or "invisible"
if AITargetType.TARGET_SHIP == self.getSourceAITarget().target_type:
shipID = self.getSourceAITarget().target_id
elif AITargetType.TARGET_FLEET == self.getSourceAITarget().target_type:
fleetID = self.getSourceAITarget().target_id
fleet = fo.getUniverse().getFleet(fleetID)
for shipID in fleet.shipIDs:
ship = universe.getShip(shipID)
if (foAI.foAIstate.getShipRole(ship.design.id) in [AIShipRoleType.SHIP_ROLE_MILITARY_INVASION, AIShipRoleType.SHIP_ROLE_BASE_INVASION]):
result = fo.issueInvadeOrder(shipID, planetID) or result #will track if at least one invasion troops successfully deployed
detailStr = ""
if result == 0:
pstealth = planet.currentMeterValue(fo.meterType.stealth)
pop = planet.currentMeterValue(fo.meterType.population)
shields = planet.currentMeterValue(fo.meterType.shield)
owner = planet.owner
detailStr= " -- planet has %.1f stealth, shields %.1f, %.1f population and is owned by empire %d"%(pstealth, shields, pop, owner)
print "Ordered troop ship ID %d to invade %s, got result %d"%(shipID, planetName, result), detailStr
if result == 0:
if 'needsEmergencyExploration' not in dir(foAI.foAIstate):
foAI.foAIstate.needsEmergencyExploration=[]
if fleet.systemID not in foAI.foAIstate.needsEmergencyExploration:
foAI.foAIstate.needsEmergencyExploration.append(fleet.systemID)
print "Due to trouble invading, adding system %d to Emergency Exploration List"%fleet.systemID
self.__executed = False
if shields >0 and owner==-1 and dumpTurn<fo.currentTurn():
dumpTurn=fo.currentTurn()
print "Universe Dump to debug invasions:"
universe.dump()
break
if result:
print "Successfully ordered troop ship(s) to invade %s, with detail%s "%(planetName, detailStr)
# military
elif AIFleetOrderType.ORDER_MILITARY == self.getAIFleetOrderType():
shipID = None
if AITargetType.TARGET_SHIP == self.getSourceAITarget().target_type:
shipID = self.getSourceAITarget().target_id
elif AITargetType.TARGET_FLEET == self.getSourceAITarget().target_type:
fleetID = self.getSourceAITarget().target_id
shipID = FleetUtilsAI.getShipIDWithRole(fleetID, AIShipRoleType.SHIP_ROLE_MILITARY)
#fo.issueFleetMoveOrder(fleetID, self.getTargetAITarget().target_id) #moving is already taken care of separately
targetSysID = self.getTargetAITarget().target_id
fleet = fo.getUniverse().getFleet(fleetID)
systemStatus = foAI.foAIstate.systemStatus.get(targetSysID, {})
if (fleet )and ( fleet.systemID==targetSysID ) and ((systemStatus.get('fleetThreat', 0) + systemStatus.get('planetThreat', 0)+ systemStatus.get('monsterThreat', 0))==0):
self.__setExecutionCompleted()
# move or resupply
elif self.getAIFleetOrderType() in [ AIFleetOrderType.ORDER_MOVE, AIFleetOrderType.ORDER_REPAIR, AIFleetOrderType.ORDER_RESUPPLY]:
fleetID = self.getSourceAITarget().target_id
system_id = self.getTargetAITarget().target_id
fleet = fo.getUniverse().getFleet(fleetID)
if system_id not in [fleet.systemID, fleet.nextSystemID] :
if self.getAIFleetOrderType() == AIFleetOrderType.ORDER_MOVE:
dest_id = system_id
else:
if self.getAIFleetOrderType() == AIFleetOrderType.ORDER_REPAIR:
fo.issueAggressionOrder(fleetID, False)
start_id = [fleet.systemID, fleet.nextSystemID][ fleet.systemID == -1 ]
dest_id = MoveUtilsAI.get_safe_path_leg_to_dest(fleetID, start_id, system_id)
print "fleet %d with order type(%s) sent to safe leg dest %s and ultimate dest %s"%(fleetID, AIFleetOrderTypeNames.name(self.getAIFleetOrderType()),
PlanetUtilsAI.sysNameIDs([dest_id]),
PlanetUtilsAI.sysNameIDs([system_id]))
fo.issueFleetMoveOrder(fleetID, dest_id)
if system_id == fleet.systemID:
if foAI.foAIstate.getFleetRole(fleetID) == AIFleetMissionType.FLEET_MISSION_EXPLORATION :
if system_id in foAI.foAIstate.needsEmergencyExploration:
del foAI.foAIstate.needsEmergencyExploration[ foAI.foAIstate.needsEmergencyExploration.index(system_id) ]
self.__setExecutionCompleted()
# split fleet
elif AIFleetOrderType.ORDER_SPLIT_FLEET == self.getAIFleetOrderType():
fleetID = self.getSourceAITarget().target_id
shipID = self.getTargetAITarget().target_id
fleet = fo.getUniverse().getFleet(fleetID)
if shipID in fleet.shipIDs:
fo.issueNewFleetOrder(str(shipID), shipID)
self.__setExecutionCompleted()
# attack
elif (AIFleetOrderType.ORDER_ATTACK == self.getAIFleetOrderType()):
fleetID = self.getSourceAITarget().target_id
systemID = self.getTargetAITarget().get_required_system_ai_targets()[0].target_id
fo.issueFleetMoveOrder(fleetID, systemID)