當前位置: 首頁>>代碼示例>>Python>>正文


Python FleetUtilsAI.getEmpireFleetIDsByRole方法代碼示例

本文整理匯總了Python中FleetUtilsAI.getEmpireFleetIDsByRole方法的典型用法代碼示例。如果您正苦於以下問題:Python FleetUtilsAI.getEmpireFleetIDsByRole方法的具體用法?Python FleetUtilsAI.getEmpireFleetIDsByRole怎麽用?Python FleetUtilsAI.getEmpireFleetIDsByRole使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在FleetUtilsAI的用法示例。


在下文中一共展示了FleetUtilsAI.getEmpireFleetIDsByRole方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: getInvasionFleets

# 需要導入模塊: import FleetUtilsAI [as 別名]
# 或者: from FleetUtilsAI import getEmpireFleetIDsByRole [as 別名]
def getInvasionFleets():
    "get invasion fleets"

    allInvasionFleetIDs = FleetUtilsAI.getEmpireFleetIDsByRole(AIFleetMissionType.FLEET_MISSION_INVASION)
    AIstate.invasionFleetIDs = FleetUtilsAI.extractFleetIDsWithoutMissionTypes(allInvasionFleetIDs)

    # get supplyable planets
    universe = fo.getUniverse()
    empire = fo.getEmpire()
    empireID = empire.empireID

    fleetSupplyableSystemIDs = empire.fleetSupplyableSystemIDs
    fleetSupplyablePlanetIDs = PlanetUtilsAI.getPlanetsInSystemsIDs(fleetSupplyableSystemIDs)

    # get competitor planets
    exploredSystemIDs = empire.exploredSystemIDs
    exploredPlanetIDs = PlanetUtilsAI.getPlanetsInSystemsIDs(exploredSystemIDs)

    allOwnedPlanetIDs = PlanetUtilsAI.getAllOwnedPlanetIDs(exploredPlanetIDs)
    # print "All Owned and Populated PlanetIDs: " + str(allOwnedPlanetIDs)

    empireOwnedPlanetIDs = PlanetUtilsAI.getOwnedPlanetsByEmpire(universe.planetIDs, empireID)
    # print "Empire Owned PlanetIDs:            " + str(empireOwnedPlanetIDs)

    competitorPlanetIDs = list(set(allOwnedPlanetIDs) - set(empireOwnedPlanetIDs))
    print "Competitor PlanetIDs:              " + str(competitorPlanetIDs)

    print ""
    print "Invasion Targeted SystemIDs:       " + str(AIstate.invasionTargetedSystemIDs)
    invasionTargetedPlanetIDs = getInvasionTargetedPlanetIDs(universe.planetIDs, AIFleetMissionType.FLEET_MISSION_INVASION, empireID)
    allInvasionTargetedSystemIDs = PlanetUtilsAI.getSystems(invasionTargetedPlanetIDs)
 
    # export invasion targeted systems for other AI modules
    AIstate.invasionTargetedSystemIDs = allInvasionTargetedSystemIDs
    print "Invasion Targeted PlanetIDs:       " + str(invasionTargetedPlanetIDs)

    invasionFleetIDs = FleetUtilsAI.getEmpireFleetIDsByRole(AIFleetMissionType.FLEET_MISSION_INVASION)
    if not invasionFleetIDs:
        print "Available Invasion Fleets:           0"
    else:
        print "Invasion FleetIDs:                 " + str(FleetUtilsAI.getEmpireFleetIDsByRole(AIFleetMissionType.FLEET_MISSION_INVASION))
 
    numInvasionFleets = len(FleetUtilsAI.extractFleetIDsWithoutMissionTypes(invasionFleetIDs))
    print "Invasion Fleets Without Missions:    " + str(numInvasionFleets)

    evaluatedPlanetIDs = list(set(competitorPlanetIDs) - set(invasionTargetedPlanetIDs))
    # print "Evaluated PlanetIDs:               " + str(evaluatedPlanetIDs)

    evaluatedPlanets = assignInvasionValues(evaluatedPlanetIDs, AIFleetMissionType.FLEET_MISSION_INVASION, fleetSupplyablePlanetIDs, empire)

    sortedPlanets = evaluatedPlanets.items()
    sortedPlanets.sort(lambda x, y: cmp(x[1], y[1]), reverse=True)

    print ""
    print "Invadable planetIDs:"
    for evaluationPair in sortedPlanets:
        print "    ID|Score: " + str(evaluationPair)

    # export opponent planets for other AI modules
    AIstate.opponentPlanetIDs = sortedPlanets
開發者ID:adesst,項目名稱:freeorion,代碼行數:62,代碼來源:InvasionAI.py

示例2: getColonyFleets

# 需要導入模塊: import FleetUtilsAI [as 別名]
# 或者: from FleetUtilsAI import getEmpireFleetIDsByRole [as 別名]
def getColonyFleets():
    # get colony fleets
    allColonyFleetIDs = FleetUtilsAI.getEmpireFleetIDsByRole(AIFleetMissionType.FLEET_MISSION_COLONISATION)
    AIstate.colonyFleetIDs = FleetUtilsAI.extractFleetIDsWithoutMissionTypes(allColonyFleetIDs)

    # get supplyable systems
    empire = fo.getEmpire()
    universe = fo.getUniverse()
    capitalID = empire.capitalID
    homeworld = universe.getPlanet(capitalID)
    speciesName = homeworld.speciesName
    species = fo.getSpecies(speciesName)

    fleetSupplyableSystemIDs = empire.fleetSupplyableSystemIDs
    fleetSupplyablePlanetIDs = PlanetUtilsAI.getPlanetsInSystemsIDs(fleetSupplyableSystemIDs)
    print "    fleetSupplyablePlanetIDs:" + str(fleetSupplyablePlanetIDs)

    # get planets
    systemIDs = foAI.foAIstate.getExplorableSystems(AIExplorableSystemType.EXPLORABLE_SYSTEM_EXPLORED)
    planetIDs = PlanetUtilsAI.getPlanetsInSystemsIDs(systemIDs)

    removeAlreadyOwnedPlanetIDs(planetIDs, AIFleetMissionType.FLEET_MISSION_COLONISATION)
    removeAlreadyOwnedPlanetIDs(planetIDs, AIFleetMissionType.FLEET_MISSION_OUTPOST)

    evaluatedPlanets = assignColonisationValues(planetIDs, AIFleetMissionType.FLEET_MISSION_COLONISATION, fleetSupplyablePlanetIDs, species, empire)
    removeLowValuePlanets(evaluatedPlanets)

    sortedPlanets = evaluatedPlanets.items()
    sortedPlanets.sort(lambda x, y: cmp(x[1], y[1]), reverse=True)

    print "Colonisable planets:"
    for evaluationPair in sortedPlanets:
        print "    ID|Score: " + str(evaluationPair)
    print ""

    # export planets for other AI modules
    AIstate.colonisablePlanetIDs = sortedPlanets

    # get outpost fleets
    allOutpostFleetIDs = FleetUtilsAI.getEmpireFleetIDsByRole(AIFleetMissionType.FLEET_MISSION_OUTPOST)
    AIstate.outpostFleetIDs = FleetUtilsAI.extractFleetIDsWithoutMissionTypes(allOutpostFleetIDs)

    evaluatedOutposts = assignColonisationValues(planetIDs, AIFleetMissionType.FLEET_MISSION_OUTPOST, fleetSupplyablePlanetIDs, species, empire)
    removeLowValuePlanets(evaluatedOutposts)

    sortedOutposts = evaluatedOutposts.items()
    sortedOutposts.sort(lambda x, y: cmp(x[1], y[1]), reverse=True)

    print "Colonisable outposts:"
    for evaluationPair in sortedOutposts:
        print "    ID|Score: " + str(evaluationPair)
    print ""

    # export outposts for other AI modules
    AIstate.colonisableOutpostIDs = sortedOutposts
開發者ID:dbuksbaum,項目名稱:FreeOrion,代碼行數:57,代碼來源:ColonisationAI.py

示例3: calculateColonisationPriority

# 需要導入模塊: import FleetUtilsAI [as 別名]
# 或者: from FleetUtilsAI import getEmpireFleetIDsByRole [as 別名]
def calculateColonisationPriority():
    "calculates the demand for colony ships by colonisable planets"
    global allottedColonyTargets
    totalPP=fo.getEmpire().productionPoints
    colonyCost=120*(1+ 0.06*len( list(AIstate.popCtrIDs) ))
    turnsToBuild=8#TODO: check for susp anim pods, build time 10
    allottedPortion = [0.4,  0.5][ random.choice([0, 1]) ]    #fo.empireID() % 2
    if ( foAI.foAIstate.getPriority(EnumsAI.AIPriorityType.PRIORITY_PRODUCTION_COLONISATION) 
            > 2 * foAI.foAIstate.getPriority(EnumsAI.AIPriorityType.PRIORITY_PRODUCTION_MILITARY)):
        allottedPortion *= 1.5
    #allottedColonyTargets = 1+ int(fo.currentTurn()/50)
    allottedColonyTargets = 1 + int( totalPP*turnsToBuild*allottedPortion/colonyCost)

    numColonisablePlanetIDs = len(    [  pid   for (pid,  (score, specName) ) in  foAI.foAIstate.colonisablePlanetIDs if score > 60 ][:allottedColonyTargets+2] )
    if (numColonisablePlanetIDs == 0): return 1

    colonyshipIDs = FleetUtilsAI.getEmpireFleetIDsByRole(EnumsAI.AIFleetMissionType.FLEET_MISSION_COLONISATION)
    numColonyships = len(FleetUtilsAI.extractFleetIDsWithoutMissionTypes(colonyshipIDs))
    colonisationPriority = 121 * (1+numColonisablePlanetIDs - numColonyships) / (numColonisablePlanetIDs+1)

    # print ""
    # print "Number of Colony Ships        : " + str(numColonyships)
    # print "Number of Colonisable planets : " + str(numColonisablePlanetIDs)
    # print "Priority for colony ships     : " + str(colonisationPriority)

    if colonisationPriority < 1: return 1

    return colonisationPriority
開發者ID:fourmond,項目名稱:freeorion,代碼行數:30,代碼來源:PriorityAI.py

示例4: assignInvasionFleetsToInvade

# 需要導入模塊: import FleetUtilsAI [as 別名]
# 或者: from FleetUtilsAI import getEmpireFleetIDsByRole [as 別名]
def assignInvasionFleetsToInvade():
    # assign fleet targets to invadable planets
    invasionFleetIDs = AIstate.invasionFleetIDs

    sendInvasionFleets(invasionFleetIDs, AIstate.invasionTargets, AIFleetMissionType.FLEET_MISSION_INVASION)
    allInvasionFleetIDs = FleetUtilsAI.getEmpireFleetIDsByRole(AIFleetMissionType.FLEET_MISSION_INVASION)
    for fid in  FleetUtilsAI.extractFleetIDsWithoutMissionTypes(allInvasionFleetIDs):
        thisMission = foAI.foAIstate.getAIFleetMission(fid)
        thisMission.checkMergers(context="Post-send consolidation of unassigned troops")
開發者ID:zweizeichen,項目名稱:freeorion,代碼行數:11,代碼來源:InvasionAI.py

示例5: calculateInvasionPriority

# 需要導入模塊: import FleetUtilsAI [as 別名]
# 或者: from FleetUtilsAI import getEmpireFleetIDsByRole [as 別名]
def calculateInvasionPriority():
    "calculates the demand for troop ships by opponent planets"
    global allottedInvasionTargets
    troopsPerPod=2
    empire=fo.getEmpire()
    
    if foAI.foAIstate.aggression==fo.aggression.beginner and fo.currentTurn()<150:
        return 0
    
    allottedInvasionTargets = 1+ int(fo.currentTurn()/25)
    totalVal= sum( [pscore for pid, pscore, trp in AIstate.invasionTargets[:allottedInvasionTargets] ] )
    troopsNeeded= sum( [(trp+4) for pid, pscore, trp in AIstate.invasionTargets[:allottedInvasionTargets] ] )

    if totalVal == 0: 
        return 0 
    opponentTroopPods = int(troopsNeeded/troopsPerPod)

    productionQueue = empire.productionQueue
    queuedTroopPods=0
    for queue_index  in range(0,  len(productionQueue)):
        element=productionQueue[queue_index]
        if element.buildType == AIEmpireProductionTypes.BT_SHIP:
             if foAI.foAIstate.getShipRole(element.designID) in  [ AIShipRoleType.SHIP_ROLE_MILITARY_INVASION,  AIShipRoleType.SHIP_ROLE_BASE_INVASION] :
                 design = fo.getShipDesign(element.designID)
                 queuedTroopPods += element.remaining*element.blocksize * list(design.parts).count("GT_TROOP_POD") 
    bestShip,  bestDesign,  buildChoices = getBestShipInfo( AIPriorityType.PRIORITY_PRODUCTION_INVASION)
    if bestDesign:
        troopsPerBestShip = troopsPerPod*(  list(bestDesign.parts).count("GT_TROOP_POD") )
    else:
        troopsPerBestShip=troopsPerPod #may actually not have any troopers available, but this num will do for now

    #don't cound troop bases here since if through misplanning cannot be used where made, cannot be redeployed
    #troopFleetIDs = FleetUtilsAI.getEmpireFleetIDsByRole(AIFleetMissionType.FLEET_MISSION_INVASION)  + FleetUtilsAI.getEmpireFleetIDsByRole(AIFleetMissionType.FLEET_MISSION_ORBITAL_INVASION)
    troopFleetIDs = FleetUtilsAI.getEmpireFleetIDsByRole(AIFleetMissionType.FLEET_MISSION_INVASION) 
    numTroopPods =  sum([ FleetUtilsAI.countPartsFleetwide(fleetID,  ["GT_TROOP_POD"]) for fleetID in  troopFleetIDs])
    troopShipsNeeded = math.ceil((opponentTroopPods - (numTroopPods+ queuedTroopPods ))/troopsPerBestShip)  
     
    #invasionPriority = max(  10+ 200*max(0,  troopShipsNeeded ) , int(0.1* totalVal) )
    invasionPriority = 20+ 120*max(0,  troopShipsNeeded )
    if invasionPriority < 0: 
        return 0
    if foAI.foAIstate.aggression==fo.aggression.beginner:
        return 0.5* invasionPriority
    else:
        return invasionPriority
開發者ID:zweizeichen,項目名稱:freeorion,代碼行數:47,代碼來源:PriorityAI.py

示例6: calculateInvasionPriority

# 需要導入模塊: import FleetUtilsAI [as 別名]
# 或者: from FleetUtilsAI import getEmpireFleetIDsByRole [as 別名]
def calculateInvasionPriority():
    "calculates the demand for troop ships by opponent planets"

    numOpponentPlanetIDs = len(AIstate.opponentPlanetIDs)
    if numOpponentPlanetIDs == 0: return 0

    troopShipIDs = FleetUtilsAI.getEmpireFleetIDsByRole(AIFleetMissionType.FLEET_MISSION_INVASION)
    numTroopShips = len(FleetUtilsAI.extractFleetIDsWithoutMissionTypes(troopShipIDs))
    invasionPriority = 105 * (numOpponentPlanetIDs - numTroopShips) / numOpponentPlanetIDs

    print ""
    print "Number of Troop Ships     : " + str(numTroopShips)
    print "Number of Opponent Planets: " + str(numOpponentPlanetIDs)
    print "Priority for Troop Ships  : " + str(invasionPriority)

    if invasionPriority < 0: return 0

    return invasionPriority
開發者ID:dbuksbaum,項目名稱:FreeOrion,代碼行數:20,代碼來源:PriorityAI.py

示例7: calculateMilitaryPriority

# 需要導入模塊: import FleetUtilsAI [as 別名]
# 或者: from FleetUtilsAI import getEmpireFleetIDsByRole [as 別名]
def calculateMilitaryPriority():
    "calculates the demand for military ships by military targeted systems"

    numMilitaryTargetedSystemIDs = len(AIstate.militaryTargetedSystemIDs)
    militaryShipIDs = FleetUtilsAI.getEmpireFleetIDsByRole(AIFleetMissionType.FLEET_MISSION_MILITARY)
    numMilitaryShips = len(FleetUtilsAI.extractFleetIDsWithoutMissionTypes(militaryShipIDs))

    # build one more military ship than military targeted systems
    militaryPriority = 100 * ((numMilitaryTargetedSystemIDs +2) - numMilitaryShips) / (numMilitaryTargetedSystemIDs + 1)

    # print ""
    # print "Number of Military Ships Without Missions: " + str(numMilitaryShips)
    # print "Number of Military Targeted Systems: " + str(numMilitaryTargetedSystemIDs)
    # print "Priority for Military Ships: " + str(militaryPriority)

    if militaryPriority < 0: return 0

    return militaryPriority
開發者ID:adesst,項目名稱:freeorion,代碼行數:20,代碼來源:PriorityAI.py

示例8: calculateColonisationPriority

# 需要導入模塊: import FleetUtilsAI [as 別名]
# 或者: from FleetUtilsAI import getEmpireFleetIDsByRole [as 別名]
def calculateColonisationPriority():
    "calculates the demand for colony ships by colonisable planets"

    numColonisablePlanetIDs = len(foAI.foAIstate.colonisablePlanetIDs)
    if (numColonisablePlanetIDs == 0): return 0

    colonyshipIDs = FleetUtilsAI.getEmpireFleetIDsByRole(AIFleetMissionType.FLEET_MISSION_COLONISATION)
    numColonyships = len(FleetUtilsAI.extractFleetIDsWithoutMissionTypes(colonyshipIDs))
    colonisationPriority = 101 * (numColonisablePlanetIDs - numColonyships) / numColonisablePlanetIDs

    # print ""
    # print "Number of Colony Ships        : " + str(numColonyships)
    # print "Number of Colonisable planets : " + str(numColonisablePlanetIDs)
    # print "Priority for colony ships     : " + str(colonisationPriority)

    if colonisationPriority < 0: return 0

    return colonisationPriority
開發者ID:anarsky,項目名稱:freeorion,代碼行數:20,代碼來源:PriorityAI.py

示例9: calculateOutpostPriority

# 需要導入模塊: import FleetUtilsAI [as 別名]
# 或者: from FleetUtilsAI import getEmpireFleetIDsByRole [as 別名]
def calculateOutpostPriority():
    "calculates the demand for outpost ships by colonisable planets"

    numOutpostPlanetIDs = len(foAI.foAIstate.colonisableOutpostIDs)
    completedTechs = getCompletedTechs()
    if numOutpostPlanetIDs == 0 or not 'CON_ENV_ENCAPSUL' in completedTechs:
        return 0

    outpostShipIDs = FleetUtilsAI.getEmpireFleetIDsByRole(AIFleetMissionType.FLEET_MISSION_OUTPOST)
    numOutpostShips = len(FleetUtilsAI.extractFleetIDsWithoutMissionTypes(outpostShipIDs))
    outpostPriority = 102 * (numOutpostPlanetIDs - numOutpostShips) / numOutpostPlanetIDs

    # print ""
    # print "Number of Outpost Ships       : " + str(numOutpostShips)
    # print "Number of Colonisable outposts: " + str(numOutpostPlanetIDs)
    print "Priority for outpost ships    : " + str(outpostPriority)

    if outpostPriority < 0: return 0

    return outpostPriority
開發者ID:anarsky,項目名稱:freeorion,代碼行數:22,代碼來源:PriorityAI.py

示例10: calculateExplorationPriority

# 需要導入模塊: import FleetUtilsAI [as 別名]
# 或者: from FleetUtilsAI import getEmpireFleetIDsByRole [as 別名]
def calculateExplorationPriority():
    "calculates the demand for scouts by unexplored systems"

    numUnexploredSystems = len(foAI.foAIstate.getExplorableSystems(AIExplorableSystemType.EXPLORABLE_SYSTEM_UNEXPLORED))

    scoutIDs = FleetUtilsAI.getEmpireFleetIDsByRole(AIFleetMissionType.FLEET_MISSION_EXPLORATION)
    numScouts = len(scoutIDs)

    if (numUnexploredSystems == 0) or (numScouts >= 2): return 0

    explorationPriority = 100 * (numUnexploredSystems - numScouts) / numUnexploredSystems

    print ""
    print "Number of Scouts            : " + str(numScouts)
    print "Number of Unexplored systems: " + str(numUnexploredSystems)
    print "Priority for scouts         : " + str(explorationPriority)

    if explorationPriority < 0: return 0

    return explorationPriority
開發者ID:dbuksbaum,項目名稱:FreeOrion,代碼行數:22,代碼來源:PriorityAI.py

示例11: sendMilitaryFleets

# 需要導入模塊: import FleetUtilsAI [as 別名]
# 或者: from FleetUtilsAI import getEmpireFleetIDsByRole [as 別名]
def sendMilitaryFleets(militaryFleetIDs, evaluatedSystems, missionType):
    "sends a list of military fleets to a list of system_value_pairs"

    if len(militaryFleetIDs) == 0:
        return

    allMilitaryFleetIDs = FleetUtilsAI.getEmpireFleetIDsByRole(AIFleetMissionType.FLEET_MISSION_MILITARY)
    AIstate.militaryFleetIDs = FleetUtilsAI.extractFleetIDsWithoutMissionTypes(allMilitaryFleetIDs)

    targets = []
    for systemID_value_pair in evaluatedSystems:  # evaluatedSystems is a dictionary
        targets.extend(int(systemID_value_pair[1]) * [systemID_value_pair[0]])
    # currentFleetSizes= dict (  [ (fleetID, len( universe.getFleet(fleetID).shipIDs) )   for fleetID in allMilitaryFleetIDs ] )
    # newFleetSizes= dict (  [ (fleetID, len( universe.getFleet(fleetID).shipIDs) )   for fleetID in AIstate.militaryFleetIDs ] )

    if len(targets) == 0:
        return

    if True:
        for fleetID in militaryFleetIDs:
            systemID = choice(targets)
            aiTarget = AITarget.AITarget(AITargetType.TARGET_SYSTEM, systemID)
            aiFleetMission = foAI.foAIstate.getAIFleetMission(fleetID)
            aiFleetMission.addAITarget(missionType, aiTarget)
        return
    else:

        i = 0
        for systemID_value_pair in evaluatedSystems:  # evaluatedSystems is a dictionary
            if i >= len(militaryFleetIDs):
                return

            fleetID = militaryFleetIDs[i]
            systemID = systemID_value_pair[0]

            aiTarget = AITarget.AITarget(AITargetType.TARGET_SYSTEM, systemID)
            aiFleetMission = foAI.foAIstate.getAIFleetMission(fleetID)
            aiFleetMission.addAITarget(missionType, aiTarget)
            i = i + 1

        return
開發者ID:anarsky,項目名稱:freeorion,代碼行數:43,代碼來源:MilitaryAI.py

示例12: calculateInvasionPriority

# 需要導入模塊: import FleetUtilsAI [as 別名]
# 或者: from FleetUtilsAI import getEmpireFleetIDsByRole [as 別名]
def calculateInvasionPriority():
    "calculates the demand for troop ships by opponent planets"
    empire=fo.getEmpire()

    numOpponentPlanetIDs = len(AIstate.opponentPlanetIDs)
    if numOpponentPlanetIDs == 0: 
        return 10  #hsould always have at least a  low lvl of production going into fleets
    opponentTroopPods = sum( [math.ceil((ptroops+1)/5) for sid, pscore, ptroops in AIstate.invasionTargets] )

    productionQueue = empire.productionQueue
    queuedTroopPods=0
    for queue_index  in range(0,  len(productionQueue)):
        element=productionQueue[queue_index]
        if element.buildType == AIEmpireProductionTypes.BT_SHIP:
             if foAI.foAIstate.getShipRole(element.designID) ==       AIShipRoleType.SHIP_ROLE_MILITARY_INVASION:
                 design = fo.getShipDesign(element.designID)
                 queuedTroopPods += element.remaining*element.blocksize * list(design.parts).count("GT_TROOP_POD") 
    bestShip,  bestDesign,  buildChoices = getBestShipInfo( AIPriorityType.PRIORITY_PRODUCTION_INVASION)
    if bestDesign:
        troopsPerBestShip = 2*(  list(bestDesign.parts).count("GT_TROOP_POD") )
    else:
        troopsPerBestShip=2 #may actually not have any troopers available, but this num will do for now

    troopFleetIDs = FleetUtilsAI.getEmpireFleetIDsByRole(AIFleetMissionType.FLEET_MISSION_INVASION)
    numTroopPods =  sum([ FleetUtilsAI.countPartsFleetwide(fleetID,  ["GT_TROOP_POD"]) for fleetID in  FleetUtilsAI.extractFleetIDsWithoutMissionTypes(troopFleetIDs)])
    troopShipsNeeded = math.ceil((opponentTroopPods - (numTroopPods+ queuedTroopPods ))/troopsPerBestShip)  
    #milFleetEquiv= math.ceil( MilitaryAI.totMilRating /   curBestMilShipRating() )
    #troopShipsNeeded = min( troopShipsNeeded ,  math.floor( milFleetEquiv / 2) - myTroopShips) # stale calcs to limit troops priority relative to current tot mil rating
     
    invasionPriority = 10+ 200*max(0,  troopShipsNeeded )

    # print ""
    # print "Number of Troop Ships Without Missions: " + str(numTroopShips)
    # print "Number of Opponent Planets:             " + str(numOpponentPlanetIDs)
    # print "Priority for Troop Ships  :             " + str(invasionPriority)
    print "Invasion Priority Calc:  Opponent TroopsPods: %d ,  my queued Pods: %d,  my fleet troop pods: %d  -- priority %d"%(opponentTroopPods,  queuedTroopPods,  numTroopPods,  invasionPriority)

    if invasionPriority < 0: return 0

    return invasionPriority
開發者ID:anarsky,項目名稱:freeorion,代碼行數:42,代碼來源:PriorityAI.py

示例13: calculateOutpostPriority

# 需要導入模塊: import FleetUtilsAI [as 別名]
# 或者: from FleetUtilsAI import getEmpireFleetIDsByRole [as 別名]
def calculateOutpostPriority():
    "calculates the demand for outpost ships by colonisable planets"
    baseOutpostCost=80

    numOutpostPlanetIDs = len(foAI.foAIstate.colonisableOutpostIDs)
    numOutpostPlanetIDs = len(    [  pid   for (pid,  (score, specName) ) in  foAI.foAIstate.colonisableOutpostIDs if score > 1.0*baseOutpostCost/3.0 ][:allottedColonyTargets] )
    completedTechs = ResearchAI.getCompletedTechs()
    if numOutpostPlanetIDs == 0 or not 'CON_ENV_ENCAPSUL' in completedTechs:
        return 0

    outpostShipIDs = FleetUtilsAI.getEmpireFleetIDsByRole(EnumsAI.AIFleetMissionType.FLEET_MISSION_OUTPOST)
    numOutpostShips = len(FleetUtilsAI.extractFleetIDsWithoutMissionTypes(outpostShipIDs))
    outpostPriority = 102 * (numOutpostPlanetIDs - numOutpostShips) / numOutpostPlanetIDs

    # print ""
    # print "Number of Outpost Ships       : " + str(numOutpostShips)
    # print "Number of Colonisable outposts: " + str(numOutpostPlanetIDs)
    print "Priority for outpost ships    : " + str(outpostPriority)

    if outpostPriority < 1: return 1

    return outpostPriority
開發者ID:fourmond,項目名稱:freeorion,代碼行數:24,代碼來源:PriorityAI.py

示例14: assignScoutsToExploreSystems

# 需要導入模塊: import FleetUtilsAI [as 別名]
# 或者: from FleetUtilsAI import getEmpireFleetIDsByRole [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

示例15: getMilitaryFleets

# 需要導入模塊: import FleetUtilsAI [as 別名]
# 或者: from FleetUtilsAI import getEmpireFleetIDsByRole [as 別名]
def getMilitaryFleets(tryReset=True):
    "get armed military fleets"
    global MilitaryAllocations, totMilRating

    universe = fo.getUniverse()
    empire = fo.getEmpire()
    empireID = empire.empireID
    capitalID = PlanetUtilsAI.getCapital()
    if capitalID == None:
        homeworld=None
    else:
        homeworld = universe.getPlanet(capitalID)
    if homeworld:
        homeSystemID = homeworld.systemID
    else:
        homeSystemID=-1

    allMilitaryFleetIDs =  FleetUtilsAI.getEmpireFleetIDsByRole(AIFleetMissionType.FLEET_MISSION_MILITARY )
    if tryReset and ((fo.currentTurn()+empireID) % 10 ==0):
        tryAgain(allMilitaryFleetIDs)
    
    totMilRating = sum(  map(lambda x: foAI.foAIstate.getRating(x).get('overall', 0),  allMilitaryFleetIDs   )  )
    milShips = 0
    for fid in allMilitaryFleetIDs:
        milShips += foAI.foAIstate.fleetStatus.get(fid,  {}).get('nships', 0)
    print "=================================================="
    print "Total Military Rating: %d"%totMilRating
    print "---------------------------------"
    foAI.foAIstate.militaryRating=totMilRating
        
    milFleetIDs = list( FleetUtilsAI.extractFleetIDsWithoutMissionTypes(allMilitaryFleetIDs))
    availMilRating = sum(  map(lambda x: foAI.foAIstate.getRating(x).get('overall', 0),  milFleetIDs   )  )
    print "=================================================="
    print "Available Military Rating: %d"%availMilRating
    print "---------------------------------"
    remainingMilRating = availMilRating
    allocations = []
    
    if milFleetIDs == []:
        MilitaryAllocations = []
        return
        
    alreadyAssignedRating={}
    for sysID in universe.systemIDs:
        alreadyAssignedRating[sysID]=0

    for fleetID in [fid for fid in allMilitaryFleetIDs if fid not in milFleetIDs]:
        aiFleetMission = foAI.foAIstate.getAIFleetMission(fleetID)
        sysTargets= []
        for aiFleetMissionType in aiFleetMission.getAIMissionTypes():
            aiTargets = aiFleetMission.getAITargets(aiFleetMissionType)
            for aiTarget in aiTargets:
                sysTargets.extend(aiTarget.getRequiredSystemAITargets())
        if not sysTargets: #shouldn't really be possible
            continue
        lastSys = sysTargets[-1].getTargetID() # will count this fleet as assigned to last system in target list
        alreadyAssignedRating[lastSys] +=  foAI.foAIstate.getRating(fleetID).get('overall', 0) #TODO: would preferably tally attack and health and take product 

    # get systems to defend
    capitalID = PlanetUtilsAI.getCapital()
    if capitalID != None:
        capitalPlanet = universe.getPlanet(capitalID)
    else:
        capitalPlanet=None
    #TODO: if no owned planets try to capture one!
    if  capitalPlanet:  
        capitalSysID = capitalPlanet.systemID
    else: # should be rare, but so as to not break code below, pick a randomish  mil-centroid  system
        systemDict = {}
        for fleetID in allMilitaryFleetIDs:
            status = foAI.foAIstate.fleetStatus.get(fleetID,  None)
            if status is not None:
                sysID = status['sysID']
                if len( list( universe.getSystem(sysID).planetIDs  ) ) ==0:
                    continue
                systemDict[sysID] = systemDict.get( sysID,  0) + status.get('rating',  {}).get('overall',  0)
        rankedSystems = sorted( [(val,  sysID) for sysID, val in systemDict.items()  ]   )
        if rankedSystems:
            capitalSysID = rankedSystems[-1][-1]
        else:
            capitalSysID = foAI.foAIstate.fleetStatus.items()[0]['sysID']

    if fo.currentTurn() < 20:
        threatBias = 0
    elif fo.currentTurn() < 40:
        threatBias = 10
    elif fo.currentTurn() < 60:
        threatBias = 80
    elif fo.currentTurn() < 80:
        threatBias = 200
    else:
        threatBias = 400
    
    threatBias = 0

    safetyFactor = [ 4.0,  3.0,  1.5,  1.0,  1.0,  0.95    ][foAI.foAIstate.aggression] 
    
    topTargetPlanets = [pid for pid, pscore, trp in AIstate.invasionTargets[:PriorityAI.allottedInvasionTargets]  if pscore > 20]  + [pid for pid,  pscore in foAI.foAIstate.colonisablePlanetIDs[:10]  if pscore > 20] 
    topTargetSystems = []
    for sysID in PlanetUtilsAI.getSystems(  topTargetPlanets  ):
#.........這裏部分代碼省略.........
開發者ID:oriongod,項目名稱:freeorion,代碼行數:103,代碼來源:MilitaryAI.py


注:本文中的FleetUtilsAI.getEmpireFleetIDsByRole方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。