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


Python MoveUtilsAI.canTravelToSystemAndReturnToResupply方法代码示例

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


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

示例1: assignScoutsToExploreSystems

# 需要导入模块: import MoveUtilsAI [as 别名]
# 或者: from MoveUtilsAI import canTravelToSystemAndReturnToResupply [as 别名]
def assignScoutsToExploreSystems():
    # TODO: use Graph Theory to explore closest systems
    universe = fo.getUniverse()
    capitalSysID = PlanetUtilsAI.getCapitalSysID()
    # order fleets to explore
    #explorableSystemIDs = foAI.foAIstate.getExplorableSystems(AIExplorableSystemType.EXPLORABLE_SYSTEM_UNEXPLORED)
    explorableSystemIDs =  list(borderUnexploredSystemIDs)
    if not explorableSystemIDs or (capitalSysID == -1):
        return
    expSystemsByDist = sorted(  map( lambda x: ( universe.linearDistance(capitalSysID, x),  x) ,  explorableSystemIDs ) )
    print "Exploration system considering following system-distance pairs:\n %s"%("[ "+ ",  ".join(["%3d : %5.1f"%(sys, dist) for dist, sys in expSystemsByDist]) +" ]")
    exploreList = [sysID for dist, sysID in expSystemsByDist ]

    alreadyCovered,  availableScouts  = getCurrentExplorationInfo()


    print "explorable sys IDs: %s"%exploreList
    print "already targeted: %s"%alreadyCovered
    if 'needsEmergencyExploration' not in dir(foAI.foAIstate):
        foAI.foAIstate.needsEmergencyExploration=[]
    needsCoverage= foAI.foAIstate.needsEmergencyExploration + [sysID for sysID in exploreList if sysID not in  alreadyCovered ] # emergency coverage cane be due to invasion detection trouble, etc.
    print "needs coverage: %s"%needsCoverage
    print "available scouts & AIstate locs: %s"%(map( lambda x: (x,  foAI.foAIstate.fleetStatus.get(x, {}).get('sysID', -1)),    availableScouts) )
    print "available scouts & universe locs: %s"%(map( lambda x: (x,  universe.getFleet(x).systemID),  availableScouts) )
    if not needsCoverage or not availableScouts:
        return

    availableScouts = set(availableScouts)
    sentList=[]
    while (len(availableScouts) > 0 ) and ( len(needsCoverage) >0):
        thisSysID = needsCoverage.pop(0)
        if (foAI.foAIstate.systemStatus.setdefault(thisSysID, {}).setdefault('monsterThreat', 0) > 2000*(foAI.foAIstate.aggression) ) or (fo.currentTurn() <20  and foAI.foAIstate.systemStatus[thisSysID]['monsterThreat'] > 200):
            print "Skipping exploration of system %d due to Big Monster,  threat %d"%(thisSysID,  foAI.foAIstate.systemStatus[thisSysID]['monsterThreat'])
            continue
        foundFleets=[]
        thisFleetList = FleetUtilsAI.getFleetsForMission(nships=1,  targetStats={},  minStats={},  curStats={},  species="",  systemsToCheck=[thisSysID],  systemsChecked=[],
                                                     fleetPoolSet = availableScouts,   fleetList=foundFleets,  verbose=False)
        if thisFleetList==[]:
            print "seem to have run out of scouts while trying to cover sysID %d"%thisSysID
            break #must have ran out of scouts
        fleetID = thisFleetList[0]
        aiFleetMission = foAI.foAIstate.getAIFleetMission( fleetID )
        aiTarget = AITarget.AITarget(AITargetType.TARGET_SYSTEM, thisSysID )
        if len(MoveUtilsAI.canTravelToSystemAndReturnToResupply(fleetID, aiFleetMission.getLocationAITarget(), aiTarget, fo.empireID())) > 0:
            aiFleetMission.addAITarget(AIFleetMissionType.FLEET_MISSION_EXPLORATION, aiTarget)
            sentList.append(thisSysID)
        else: #system too far out, skip it, but can add scout back to available pool
            print "sysID %d too far out for fleet ( ID %d ) to readch"%(thisSysID,  fleetID)
            availableScouts.update(thisFleetList)
    print "sent scouting fleets to sysIDs : %s"%sentList
    return
    # pylint: disable=pointless-string-statement
    """
开发者ID:fatman2021,项目名称:FreeOrion,代码行数:55,代码来源:ExplorationAI.py

示例2: assignScoutsToExploreSystems

# 需要导入模块: import MoveUtilsAI [as 别名]
# 或者: from MoveUtilsAI import canTravelToSystemAndReturnToResupply [as 别名]
def assignScoutsToExploreSystems():
    # TODO: use Graph Theory to explore closest systems

    fleetIDs = FleetUtilsAI.getEmpireFleetIDsByRole(AIFleetMissionType.FLEET_MISSION_EXPLORATION)

    # order fleets to explore
    explorableSystemIDs = foAI.foAIstate.getExplorableSystems(AIExplorableSystemType.EXPLORABLE_SYSTEM_UNEXPLORED)
    for fleetID in fleetIDs:
        # if fleet already has a mission, continue
        aiFleetMission = foAI.foAIstate.getAIFleetMission(fleetID)
        if len(aiFleetMission.getAIMissionTypes()) > 0:
            continue

        # else send fleet to a system
        for systemID in explorableSystemIDs:
            # if system is already being explored, continue
            aiTarget = AITarget.AITarget(AITargetType.TARGET_SYSTEM, systemID)
            if foAI.foAIstate.hasAITarget(AIFleetMissionType.FLEET_MISSION_EXPLORATION, aiTarget):
                continue

            # add exploration mission to fleet with target unexplored system and this system is in range
            if len(MoveUtilsAI.canTravelToSystemAndReturnToResupply(fleetID, aiFleetMission.getLocationAITarget(), aiTarget, fo.empireID())) > 0:
                aiFleetMission.addAITarget(AIFleetMissionType.FLEET_MISSION_EXPLORATION, aiTarget)
                break
开发者ID:adesst,项目名称:freeorion,代码行数:26,代码来源:ExplorationAI.py


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