本文整理汇总了Python中ProductionAI.curBestMilShipCost方法的典型用法代码示例。如果您正苦于以下问题:Python ProductionAI.curBestMilShipCost方法的具体用法?Python ProductionAI.curBestMilShipCost怎么用?Python ProductionAI.curBestMilShipCost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProductionAI
的用法示例。
在下文中一共展示了ProductionAI.curBestMilShipCost方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: calculateMilitaryPriority
# 需要导入模块: import ProductionAI [as 别名]
# 或者: from ProductionAI import curBestMilShipCost [as 别名]
def calculateMilitaryPriority():
"""calculates the demand for military ships by military targeted systems"""
global unmetThreat
universe = fo.getUniverse()
empire = fo.getEmpire()
empireID = empire.empireID
capitalID = PlanetUtilsAI.get_capital()
if capitalID is not None and capitalID != -1:
homeworld = universe.getPlanet(capitalID)
else:
return 0# no capitol (not even a capitol-in-the-making), means can't produce any ships
have_l1_weaps = (tech_is_complete("SHP_WEAPON_1_4") or
tech_is_complete("SHP_WEAPON_2_1") or
tech_is_complete("SHP_WEAPON_4_1"))
have_l2_weaps = (tech_is_complete("SHP_WEAPON_2_3") or
tech_is_complete("SHP_WEAPON_4_1"))
enemies_sighted = foAI.foAIstate.misc.get('enemies_sighted',{})
allottedInvasionTargets = 1+ int(fo.currentTurn()/25)
targetPlanetIDs = [pid for pid, pscore, trp in AIstate.invasionTargets[:allottedInvasionTargets] ] + [pid for pid, pscore in foAI.foAIstate.colonisablePlanetIDs[:allottedColonyTargets] ] + [pid for pid, pscore in foAI.foAIstate.colonisableOutpostIDs[:allottedColonyTargets] ]
mySystems = set( AIstate.popCtrSystemIDs ).union( AIstate.outpostSystemIDs )
targetSystems = set( PlanetUtilsAI.get_systems(targetPlanetIDs) )
curShipRating = ProductionAI.curBestMilShipRating()
cSRR = curShipRating**0.5
defense_ships_needed = 0
currentTurn=fo.currentTurn()
ships_needed=0
defense_ships_needed = 0
ships_needed_allocation = []
for sysID in mySystems.union(targetSystems) :
status=foAI.foAIstate.systemStatus.get( sysID, {} )
myRating = status.get('myFleetRating', 0)
my_defenses = status.get('mydefenses', {}).get('overall', 0)
baseMonsterThreat = status.get('monsterThreat', 0)
#scale monster threat so that in early - mid game big monsters don't over-drive military production
monsterThreat = baseMonsterThreat
if currentTurn>200:
pass
elif currentTurn>100:
if baseMonsterThreat >=2000:
monsterThreat = 2000 + (currentTurn/100.0 - 1) *(baseMonsterThreat-2000)
elif currentTurn>30:
if baseMonsterThreat >=2000:
monsterThreat = 0
else:
if baseMonsterThreat >200:
monsterThreat = 0
if sysID in mySystems:
threatRoot = status.get('fleetThreat', 0)**0.5 + 0.8*status.get('max_neighbor_threat', 0)**0.5 + 0.2*status.get('neighborThreat', 0)**0.5 + monsterThreat**0.5 + status.get('planetThreat', 0)**0.5
else:
threatRoot = status.get('fleetThreat', 0)**0.5 + monsterThreat**0.5 + status.get('planetThreat', 0)**0.5
ships_needed_here = math.ceil(( max(0, (threatRoot - (myRating**0.5 + my_defenses**0.5)))**2)/curShipRating)
ships_needed += ships_needed_here
ships_needed_allocation.append((sysID, ships_needed_here))
if sysID in mySystems:
defense_ships_needed += ships_needed_here
scale = (75 + ProductionAI.curBestMilShipCost()) / 2.0
#militaryPriority = int( 40 + max(0, 75*unmetThreat / curShipRating) )
part1 = min(1*fo.currentTurn(), 40)
part2 = max(0, int(75*ships_needed) )
militaryPriority = part1 + part2
#militaryPriority = min(1*fo.currentTurn(), 40) + max(0, int(scale*ships_needed))
if not have_l1_weaps:
militaryPriority /= 2.0
elif not (have_l2_weaps and enemies_sighted):
militaryPriority /= 1.5
#print "Calculating Military Priority: 40 + 75 * unmetThreat/curShipRating \n\t Priority: %d \t unmetThreat %.0f curShipRating: %.0f"%(militaryPriority, unmetThreat, curShipRating)
fmt_string = "Calculating Military Priority: min(t,40) + %d * ships_needed \n\t Priority: %d \t ships_needed: %d \t defense_ships_needed: %d \t curShipRating: %.0f \t l1_weaps: %s \t enemies_sighted: %s"
print fmt_string%(scale, militaryPriority, ships_needed, defense_ships_needed, curShipRating, have_l1_weaps, enemies_sighted)
print "Source of milship demand: ", ships_needed_allocation
if foAI.foAIstate.aggression < fo.aggression.typical:
militaryPriority *= (1.0 + foAI.foAIstate.aggression) / (1.0 + fo.aggression.typical)
return max( militaryPriority, 0)
示例2: calculateMilitaryPriority
# 需要导入模块: import ProductionAI [as 别名]
# 或者: from ProductionAI import curBestMilShipCost [as 别名]
def calculateMilitaryPriority():
"calculates the demand for military ships by military targeted systems"
global unmetThreat
universe = fo.getUniverse()
empire = fo.getEmpire()
empireID = empire.empireID
capitalID = PlanetUtilsAI.getCapital()
if capitalID is not None and capitalID != -1:
homeworld = universe.getPlanet(capitalID)
else:
return 0# no capitol (not even a capitol-in-the-making), means can't produce any ships
have_mod_weaps = ( empire.getTechStatus("SHP_WEAPON_1_4") == fo.techStatus.complete or
empire.getTechStatus("SHP_WEAPON_2_1") == fo.techStatus.complete or
empire.getTechStatus("SHP_WEAPON_4_1") == fo.techStatus.complete )
allottedInvasionTargets = 1+ int(fo.currentTurn()/25)
targetPlanetIDs = [pid for pid, pscore, trp in AIstate.invasionTargets[:allottedInvasionTargets] ] + [pid for pid, pscore in foAI.foAIstate.colonisablePlanetIDs[:allottedColonyTargets] ] + [pid for pid, pscore in foAI.foAIstate.colonisableOutpostIDs[:allottedColonyTargets] ]
mySystems = set( AIstate.popCtrSystemIDs ).union( AIstate.outpostSystemIDs )
targetSystems = set( PlanetUtilsAI.getSystems(targetPlanetIDs) )
curShipRating = ProductionAI.curBestMilShipRating()
cSRR = curShipRating**0.5
unmetThreat = 0.0
currentTurn=fo.currentTurn()
shipsNeeded=0
defenses_needed = 0
for sysID in mySystems.union(targetSystems) :
status=foAI.foAIstate.systemStatus.get( sysID, {} )
myRating = status.get('myFleetRating', 0)
my_defenses = status.get('mydefenses', {}).get('overall', 0)
baseMonsterThreat = status.get('monsterThreat', 0)
#scale monster threat so that in early - mid game big monsters don't over-drive military production
monsterThreat = baseMonsterThreat
if currentTurn>200:
pass
elif currentTurn>100:
if baseMonsterThreat >=2000:
monsterThreat = 2000 + (currentTurn/100.0 - 1) *(baseMonsterThreat-2000)
elif currentTurn>30:
if baseMonsterThreat >=2000:
monsterThreat = 0
else:
if baseMonsterThreat >200:
monsterThreat = 0
if sysID in mySystems:
threatRoot = status.get('fleetThreat', 0)**0.5 + 0.8*status.get('max_neighbor_threat', 0)**0.5 + 0.2*status.get('neighborThreat', 0)**0.5 + monsterThreat**0.5 + status.get('planetThreat', 0)**0.5
else:
threatRoot = status.get('fleetThreat', 0)**0.5 + monsterThreat**0.5 + status.get('planetThreat', 0)**0.5
shipsNeeded += math.ceil(( max(0, (threatRoot - (myRating**0.5 + my_defenses**0.5)))**2)/curShipRating)
scale = (75 + ProductionAI.curBestMilShipCost()) / 2.0
#militaryPriority = int( 40 + max(0, 75*unmetThreat / curShipRating) )
militaryPriority = min(1*fo.currentTurn(), 40) + max(0, int(75*shipsNeeded) )
#militaryPriority = min(1*fo.currentTurn(), 40) + max(0, int(scale*shipsNeeded) )
if not have_mod_weaps:
militaryPriority /= 2
#print "Calculating Military Priority: 40 + 75 * unmetThreat/curShipRating \n\t Priority: %d \t unmetThreat %.0f curShipRating: %.0f"%(militaryPriority, unmetThreat, curShipRating)
print "Calculating Military Priority: 40 + 75 * shipsNeeded \n\t Priority: %d \t shipsNeeded %d \t unmetThreat %.0f curShipRating: %.0f"%(militaryPriority, shipsNeeded, unmetThreat, curShipRating)
return max( militaryPriority, 0)