本文整理匯總了Python中FleetUtilsAI.getEmpireFleetIDs方法的典型用法代碼示例。如果您正苦於以下問題:Python FleetUtilsAI.getEmpireFleetIDs方法的具體用法?Python FleetUtilsAI.getEmpireFleetIDs怎麽用?Python FleetUtilsAI.getEmpireFleetIDs使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類FleetUtilsAI
的用法示例。
在下文中一共展示了FleetUtilsAI.getEmpireFleetIDs方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: clean
# 需要導入模塊: import FleetUtilsAI [as 別名]
# 或者: from FleetUtilsAI import getEmpireFleetIDs [as 別名]
def clean(self):
global invasionTargets
"turn start AIstate cleanup"
fleetsLostBySystem.clear()
fleetsLostByID.clear()
invasionTargets=[]
ExplorationAI.graphFlags.clear()
print "-------------------------------------------------"
print "Border Exploration Update"
print "-------------------------------------------------"
for sysID in list(self.visBorderSystemIDs):
ExplorationAI.followVisSystemConnections(sysID, self.origHomeSystemID)
newlyExplored = ExplorationAI.updateExploredSystems()
nametags=[]
universe = fo.getUniverse()
for sysID in newlyExplored:
newsys = universe.getSystem(sysID)
nametags.append( "ID:%4d -- %20s"%(sysID, (newsys and newsys.name) or"name unknown" ) )# an explored system *should* always be able to be gotten
if newlyExplored:
print "-------------------------------------------------"
print "newly explored systems: \n"+"\n".join(nametags)
print "-------------------------------------------------"
# cleanup fleet roles
#self.updateFleetLocs()
self.__cleanFleetRoles()
self.__cleanAIFleetMissions(FleetUtilsAI.getEmpireFleetIDs())
print "Fleets lost by system: %s"%fleetsLostBySystem
self.updateSystemStatus()
ExplorationAI.updateScoutFleets() #should do this after clearing dead fleets, currently should be already done here
示例2: generateOrders
# 需要導入模塊: import FleetUtilsAI [as 別名]
# 或者: from FleetUtilsAI import getEmpireFleetIDs [as 別名]
def generateOrders():
empire = fo.getEmpire()
print "Empire: " + empire.name + " TURN: " + str(fo.currentTurn())
print "Capital: " + str(empire.capitalID)
# turn cleanup
splitFleet()
identifyShipDesigns()
identifyFleetsRoles()
foAIstate.clean(ExplorationAI.getHomeSystemID(), FleetUtilsAI.getEmpireFleetIDs())
# ...missions
# ...demands/priorities
# call AI modules
PriorityAI.calculatePriorities()
ExplorationAI.assignScoutsToExploreSystems()
ColonisationAI.assignColonyFleetsToColonise()
InvasionAI.assignInvasionFleetsToInvade()
FleetUtilsAI.generateAIFleetOrdersForAIFleetMissions()
FleetUtilsAI.issueAIFleetOrdersForAIFleetMissions()
ResearchAI.generateResearchOrders()
ProductionAI.generateProductionOrders()
ResourcesAI.generateResourcesOrders()
foAIstate.afterTurnCleanup()
fo.doneTurn()
示例3: splitNewFleets
# 需要導入模塊: import FleetUtilsAI [as 別名]
# 或者: from FleetUtilsAI import getEmpireFleetIDs [as 別名]
def splitNewFleets():
"split any fleets (at creation, can have unplanned mix of ship roles)"
print "Review of current Fleet Role/Mission records:"
print "--------------------"
print "Map of Roles keyed by Fleet ID: %s"%foAIstate.getFleetRolesMap()
print "--------------------"
print "Map of Missions keyed by ID:"
for item in foAIstate.getFleetMissionsMap().items():
print " %4d : %s "%item
print "--------------------"
# TODO: check length of fleets for losses or do in AIstat.__cleanRoles
knownFleets= foAIstate.getFleetRolesMap().keys()
foAIstate.newlySplitFleets.clear()
splitableFleets=[]
for fleetID in FleetUtilsAI.getEmpireFleetIDs():
if fleetID in knownFleets: #not a new fleet
continue
else:
splitableFleets.append(fleetID)
if splitableFleets:
universe=fo.getUniverse()
print ("splitting new fleets")
for fleetID in splitableFleets:
fleet = universe.getFleet(fleetID)
if not fleet:
print "Error splittting new fleets; resulting fleet ID %d appears to not exist"%fleetID
continue
fleetLen = len(list(fleet.shipIDs))
if fleetLen ==1:
continue
newFleets = FleetUtilsAI.splitFleet(fleetID) # try splitting fleet
print "\t from splitting fleet ID %4d with %d ships, got %d new fleets:"%(fleetID, fleetLen, len(newFleets))
示例4: generateOrders
# 需要導入模塊: import FleetUtilsAI [as 別名]
# 或者: from FleetUtilsAI import getEmpireFleetIDs [as 別名]
def generateOrders():
print ("Genearting Orders")
universe = fo.getUniverse()
empire = fo.getEmpire()
planetID = empire.capitalID
planet = universe.getPlanet(planetID)
print "EmpireID: " + str(empire.empireID) + " Name: " + empire.name + " Turn: " + str(fo.currentTurn())
print "CapitalID: " + str(planetID) + " Name: " + planet.name + " Species: " + planet.speciesName
# turn cleanup
splitFleet()
identifyShipDesigns()
identifyFleetsRoles()
foAIstate.clean(ExplorationAI.getHomeSystemID(), FleetUtilsAI.getEmpireFleetIDs())
# ...missions
# ...demands/priorities
print("Calling AI Modules")
# call AI modules
PriorityAI.calculatePriorities()
ExplorationAI.assignScoutsToExploreSystems()
ColonisationAI.assignColonyFleetsToColonise()
InvasionAI.assignInvasionFleetsToInvade()
MilitaryAI.assignMilitaryFleetsToSystems()
FleetUtilsAI.generateAIFleetOrdersForAIFleetMissions()
FleetUtilsAI.issueAIFleetOrdersForAIFleetMissions()
ResearchAI.generateResearchOrders()
ProductionAI.generateProductionOrders()
ResourcesAI.generateResourcesOrders()
foAIstate.afterTurnCleanup()
fo.doneTurn()
示例5: sessionStartCleanup
# 需要導入模塊: import FleetUtilsAI [as 別名]
# 或者: from FleetUtilsAI import getEmpireFleetIDs [as 別名]
def sessionStartCleanup(self):
ResourcesAI.newTargets.clear()
self.newlySplitFleets={}
for fleetID in FleetUtilsAI.getEmpireFleetIDs():
self.getFleetRole(fleetID) #
self.getRating(fleetID) #
self.ensureHaveFleetMissions([fleetID])
self.__cleanFleetRoles(justResumed=True)
fleetsLostBySystem.clear()
fleetsLostByID.clear()
popCtrSystemIDs[:] = []#resets without detroying existing references
colonizedSystems.clear()
empireStars.clear()
popCtrIDs[:] = []
outpostIDs[:] = []
outpostSystemIDs[:] = []
示例6: clean
# 需要導入模塊: import FleetUtilsAI [as 別名]
# 或者: from FleetUtilsAI import getEmpireFleetIDs [as 別名]
def clean(self):
"turn start AIstate cleanup"
fleetsLostBySystem.clear()
fleetsLostByID.clear()
invasionTargets[:]=[]
exploration_center = PlanetUtilsAI.getCapitalSysID()
if exploration_center == -1: #a bad state probably from an old savegame
exploration_center = self.origHomeSystemID
ExplorationAI.graphFlags.clear()
if fo.currentTurn() < 50:
print "-------------------------------------------------"
print "Border Exploration Update (relative to %s"%(PlanetUtilsAI.sysNameIDs([exploration_center, -1])[0])
print "-------------------------------------------------"
if self.visBorderSystemIDs.keys() == [-1]:
self.visBorderSystemIDs.clear()
self.visBorderSystemIDs[exploration_center] = 1
for sysID in list(self.visBorderSystemIDs):
if fo.currentTurn() < 50:
print "Considering border system %s"%(PlanetUtilsAI.sysNameIDs([sysID, -1])[0])
ExplorationAI.followVisSystemConnections(sysID, exploration_center)
newlyExplored = ExplorationAI.updateExploredSystems()
nametags=[]
universe = fo.getUniverse()
for sysID in newlyExplored:
newsys = universe.getSystem(sysID)
nametags.append( "ID:%4d -- %20s"%(sysID, (newsys and newsys.name) or"name unknown" ) )# an explored system *should* always be able to be gotten
if newlyExplored:
print "-------------------------------------------------"
print "newly explored systems: \n"+"\n".join(nametags)
print "-------------------------------------------------"
# cleanup fleet roles
#self.updateFleetLocs()
self.__cleanFleetRoles()
self.__cleanAIFleetMissions(FleetUtilsAI.getEmpireFleetIDs())
print "Fleets lost by system: %s"%fleetsLostBySystem
self.updateSystemStatus()
ExplorationAI.updateScoutFleets() #should do this after clearing dead fleets, currently should be already done here
示例7: __cleanFleetRoles
# 需要導入模塊: import FleetUtilsAI [as 別名]
# 或者: from FleetUtilsAI import getEmpireFleetIDs [as 別名]
def __cleanFleetRoles(self, justResumed=False):
"removes fleetRoles if a fleet has been lost, and update fleet Ratings"
for sysID in self.systemStatus:
self.systemStatus[sysID]['myFleetRating']=0
#deleteRoles = []
universe = fo.getUniverse()
okFleets=FleetUtilsAI.getEmpireFleetIDs()
fleetList = sorted( list( self.__fleetRoleByID ))
unaccountedFleets = set( okFleets ) - set( fleetList )
shipCount=0
print "----------------------------------------------------------------------------------"
print "in CleanFleetRoles"
print "fleetList : %s"%fleetList
print "-----------"
print "FleetUtils empire-owned fleetList : %s"%okFleets
print "-----------"
if unaccountedFleets:
print "Fleets unaccounted for in Empire Records: ", unaccountedFleets
print "-----------"
#print "statusList %s"%[self.fleetStatus[fid] for fid in sorted( self.fleetStatus.keys() ) ]
print "-----------"
minThreatRating = {'overall':MinThreat, 'attack':MinThreat**0.5, 'health':MinThreat**0.5}
fighters = { (0, ((0, 0),), 0.0, 5.0):[0] } # start with a dummy entry
for fleetID in fleetList:
status=self.fleetStatus.setdefault(fleetID, {} )
rating = status.get('rating', {'overall':0, 'attack':0, 'health':0} )
newRating = self.rateFleet(fleetID, self.fleet_summary_to_estats([(1, self.empire_standard_enemy)]))
oldSysID = status.get('sysID', -2)
fleet = universe.getFleet(fleetID)
#if fleet and not fleet.aggressive:
# fleet.setAggressive(True)
if fleet:
sysID = fleet.systemID
if oldSysID in [-2, -1]:
oldSysID = sysID
status['nships']=len(fleet.shipIDs)
shipCount += status['nships']
else:
sysID = oldSysID #can still retrieve a fleet object even if fleet was just destroyed, so shouldn't get here
if (fleetID not in okFleets):# or fleet.empty:
if not ( (self.__fleetRoleByID.get(fleetID, -1) ==-1) ):
if not justResumed:
if rating.get('overall', 0) > MinThreat:
fleetsLostBySystem.setdefault(oldSysID, []).append( rating )
else:
fleetsLostBySystem.setdefault(oldSysID, []).append( minThreatRating )
sys=universe.getSystem(sysID)
sysName=(sys and sys.name) or "unknown"
#print "Fleet %d with role %s was used up, lost or destroyed at sys (%d) %s"%(fleetID, self.__fleetRoleByID[fleetID], sysID, sysName) #perhaps diff message for successful colony fleets
if fleetID in self.__fleetRoleByID:
del self.__fleetRoleByID[fleetID]
if fleetID in self.__aiMissionsByFleetID:
del self.__aiMissionsByFleetID[fleetID]
if fleetID in self.fleetStatus:
del self.fleetStatus[fleetID]
continue
else:#fleet in ok fleets
sys1 = universe.getSystem(sysID)
if sysID==-1:
sys1Name = 'starlane'
else:
sys1Name = (sys1 and sys1.name ) or "unknown"
nextSysID = fleet.nextSystemID
sys2 = universe.getSystem(nextSysID)
if nextSysID==-1:
sys2Name= 'starlane'
else:
sys2Name = (sys2 and sys2.name ) or "unknown"
print "Fleet %d (%s) oldRating: %6d | newRating %6d | at system %d (%s) | next system %d (%s)"%(fleetID, fleet.name, rating.get('overall', 0), newRating.get('overall', 0),
fleet.systemID, sys1Name, fleet.nextSystemID, sys2Name)
print "Fleet %d (%s) summary: %s"%(fleetID, fleet.name, rating.get('summary', None) )
status['rating'] = newRating
for count, sum_stats in newRating['summary']:
if sum_stats[0] > 0:
fighters.setdefault( sum_stats, [0])[0] += count
if nextSysID !=-1:
status['sysID'] = nextSysID
elif sysID !=-1:
status['sysID'] = sysID
else:
mainFleetMission=self.getAIFleetMission(fleetID)
mainMissionType = (mainFleetMission.getAIMissionTypes() + [-1])[0]
if mainMissionType != -1:
mainMissionTargets = mainFleetMission.getAITargets(mainMissionType)
if mainMissionTargets:
mMT0=mainMissionTargets[0]
if mMT0.target_type == AITargetType.TARGET_SYSTEM:
status['sysID'] = mMT0.target_id #hmm, but might still be a fair ways from here
self.shipCount = shipCount
std_fighter = sorted( [ (v, k) for k, v in fighters.items()] )[-1][1]
self.empire_standard_fighter = std_fighter
print "------------------------"
print "Empire Ship Count: ", shipCount
print "Empire standard fighter summary: ", std_fighter
print "------------------------"
示例8: __cleanFleetRoles
# 需要導入模塊: import FleetUtilsAI [as 別名]
# 或者: from FleetUtilsAI import getEmpireFleetIDs [as 別名]
def __cleanFleetRoles(self, justResumed=False):
"removes fleetRoles if a fleet has been lost, and update fleet Ratings"
global fleetsLostBySystem
for sysID in self.systemStatus:
self.systemStatus[sysID]['myFleetRating']=0
#deleteRoles = []
universe = fo.getUniverse()
okFleets=FleetUtilsAI.getEmpireFleetIDs()
fleetList = sorted( list( self.__fleetRoleByID ))
print "----------------------------------------------------------------------------------"
print "in CleanFleetRoles"
print "fleetList : %s"%fleetList
print "-----------"
print "FleetUtils empire-owned fleetList : %s"%okFleets
print "-----------"
print "statusList %s"%[self.fleetStatus[fid] for fid in sorted( self.fleetStatus.keys() ) ]
print "-----------"
for fleetID in fleetList:
status=self.fleetStatus.get(fleetID, {} )
rating = status.get('rating', {})
newRating = self.rateFleet(fleetID)
oldSysID = status.get('sysID', -2)
fleet = universe.getFleet(fleetID)
#if fleet and not fleet.aggressive:
# fleet.setAggressive(True)
if fleet:
sysID = fleet.systemID
else:
sysID = oldSysID #can still retrieve a fleet object even if fleet was just destroyed
if (fleetID not in okFleets):# or fleet.empty:
if not ( (self.__fleetRoleByID.get(fleetID, -1) ==-1) ):
if not justResumed:
fleetsLostBySystem.setdefault(sysID, []).append( max(rating.get('overall', 0), MinThreat) )
sys=universe.getSystem(sysID)
sysName=(sys and sys.name) or "unknown"
print "Fleet %d with role %s was used up, lost or destroyed at sys (%d) %s"%(fleetID, self.__fleetRoleByID[fleetID], sysID, sysName) #perhaps diff message for successful colony fleets
if fleetID in self.__fleetRoleByID:
del self.__fleetRoleByID[fleetID]
if fleetID in self.__aiMissionsByFleetID:
del self.__aiMissionsByFleetID[fleetID]
if fleetID in self.fleetStatus:
del self.fleetStatus[fleetID]
continue
else:#fleet not in ok fleets
sys1 = universe.getSystem(sysID)
sys1Name = (sys1 and sys1.name ) or "unknown"
sys2 = universe.getSystem(fleet.nextSystemID)
sys2Name = (sys2 and sys2.name ) or "unknown"
print "Fleet %d (%s) oldRating: %6d | newRating %6d | at system %d (%s) | next system %d (%s)"%(fleetID, fleet.name, rating.get('overall', 0), newRating.get('overall', 0),
fleet.systemID, sys1Name, fleet.nextSystemID, sys2Name)
status['rating'] = newRating
if sysID !=-1:
status['sysID'] = sysID
elif fleet.nextSystemID !=-1:
status['sysID'] = fleet.nextSystemID
else:
mainFleetMission=self.getAIFleetMission(fleetID)
mainMissionType = (mainFleetMission.getAIMissionTypes() + [-1])[0]
if mainMissionType != -1:
mainMissionTargets = mainFleetMission.getAITargets(mainMissionType)
if mainMissionTargets:
mMT0=mainMissionTargets[0]
if mMT0.getAITargetType()==AITargetType.TARGET_SYSTEM:
status['sysID'] = mMT0.getTargetID() #hmm, but might still be a fair ways from here
#status['sysID'] = (fleet.systemID != -1 and fleet.systemID ) or fleet.nextSystemID #universe should still give fleet & fleet.systemID even if just destroyed
self.fleetStatus[fleetID] = status
示例9: updateFleetsRoles
# 需要導入模塊: import FleetUtilsAI [as 別名]
# 或者: from FleetUtilsAI import getEmpireFleetIDs [as 別名]
def updateFleetsRoles():
"updating fleet role records"
print ("Updating fleet role records")
# assign roles to fleets
for fleetID in FleetUtilsAI.getEmpireFleetIDs():
foAIstate.getFleetRole(fleetID) #force assessment if not previously known