本文整理汇总了Python中ColonisationAI.have_gas_giant方法的典型用法代码示例。如果您正苦于以下问题:Python ColonisationAI.have_gas_giant方法的具体用法?Python ColonisationAI.have_gas_giant怎么用?Python ColonisationAI.have_gas_giant使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ColonisationAI
的用法示例。
在下文中一共展示了ColonisationAI.have_gas_giant方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _calculate_research_priority
# 需要导入模块: import ColonisationAI [as 别名]
# 或者: from ColonisationAI import have_gas_giant [as 别名]
def _calculate_research_priority():
"""Calculates the AI empire's demand for research."""
universe = fo.getUniverse()
empire = fo.getEmpire()
empire_id = empire.empireID
current_turn = fo.currentTurn()
enemies_sighted = foAI.foAIstate.misc.get('enemies_sighted', {})
recent_enemies = [x for x in enemies_sighted if x > current_turn - 8]
industry_priority = foAI.foAIstate.get_priority(PriorityType.RESOURCE_PRODUCTION)
got_algo = tech_is_complete(AIDependencies.LRN_ALGO_ELEGANCE)
got_quant = tech_is_complete(AIDependencies.LRN_QUANT_NET)
research_queue_list = ResearchAI.get_research_queue_techs()
orb_gen_tech = AIDependencies.PRO_ORBITAL_GEN
got_orb_gen = tech_is_complete(orb_gen_tech)
mgrav_prod_tech = AIDependencies.PRO_MICROGRAV_MAN
got_mgrav_prod = tech_is_complete(mgrav_prod_tech)
# got_solar_gen = tech_is_complete(AIDependencies.PRO_SOL_ORB_GEN)
milestone_techs = ["PRO_SENTIENT_AUTOMATION", "LRN_DISTRIB_THOUGHT", "LRN_QUANT_NET", "SHP_WEAPON_2_4", "SHP_WEAPON_3_2", "SHP_WEAPON_4_2"]
milestones_done = [mstone for mstone in milestone_techs if tech_is_complete(mstone)]
print "Research Milestones accomplished at turn %d: %s" % (current_turn, milestones_done)
total_pp = empire.productionPoints
total_rp = empire.resourceProduction(fo.resourceType.research)
industry_surge = ((foAI.foAIstate.aggression > fo.aggression.cautious) and
((total_pp + 1.6 * total_rp) < (50 * foAI.foAIstate.aggression)) and
(((orb_gen_tech in research_queue_list[:2] or got_orb_gen) and ColonisationAI.have_gas_giant()) or
((mgrav_prod_tech in research_queue_list[:2] or got_mgrav_prod) and ColonisationAI.have_asteroids())) and
(not (len(AIstate.popCtrIDs) >= 12)))
# get current industry production & Target
owned_planet_ids = PlanetUtilsAI.get_owned_planets_by_empire(universe.planetIDs)
planets = map(universe.getPlanet, owned_planet_ids)
target_rp = sum(map(lambda x: x.currentMeterValue(fo.meterType.targetResearch), planets))
galaxy_is_sparse = ColonisationAI.galaxy_is_sparse()
enemies_sighted = foAI.foAIstate.misc.get('enemies_sighted', {})
style_index = empire_id % 2
if foAI.foAIstate.aggression >= fo.aggression.maniacal:
style_index += 1
cutoff_sets = [[25, 45, 70, 110], [30, 45, 70, 150], [25, 40, 80, 160]]
cutoffs = cutoff_sets[style_index]
settings = [[1.3, .7, .5, .4, .35], [1.4, 0.8, 0.6, 0.5, 0.35], [1.4, 0.8, 0.6, 0.5, 0.4]][style_index]
if (current_turn < cutoffs[0]) or (not got_algo) or ((style_index == 0) and not got_orb_gen and (current_turn < cutoffs[1])):
research_priority = settings[0] * industry_priority # high research at beginning of game to get easy gro tech and to get research booster Algotrithmic Elegance
elif (not got_orb_gen) or (current_turn < cutoffs[1]):
research_priority = settings[1] * industry_priority # med-high research
elif current_turn < cutoffs[2]:
research_priority = settings[2] * industry_priority # med-high industry
elif current_turn < cutoffs[3]:
research_priority = settings[3] * industry_priority # med-high industry
else:
research_queue = list(empire.researchQueue)
research_priority = settings[4] * industry_priority # high industry , low research
if len(research_queue) == 0:
research_priority = 0 # done with research
elif len(research_queue) < 5 and research_queue[-1].allocation > 0:
research_priority = len(research_queue) * 0.01 * industry_priority # barely not done with research
elif len(research_queue) < 10 and research_queue[-1].allocation > 0:
research_priority = (4 + 2 * len(research_queue)) * 0.01 * industry_priority # almost done with research
elif len(research_queue) < 20 and research_queue[int(len(research_queue) / 2)].allocation > 0:
research_priority *= 0.7 # closing in on end of research
if industry_surge:
if galaxy_is_sparse and not any(enemies_sighted):
research_priority *= 0.5
else:
research_priority *= 0.8
if ((tech_is_complete("SHP_WEAPON_2_4") or
tech_is_complete("SHP_WEAPON_4_1")) and
tech_is_complete(AIDependencies.PROD_AUTO_NAME)):
# industry_factor = [ [0.25, 0.2], [0.3, 0.25], [0.3, 0.25] ][styleIndex ]
# researchPriority = min(researchPriority, industry_factor[got_solar_gen]*industryPriority)
research_priority *= 0.9
if got_quant:
research_priority = min(research_priority + 0.1 * industry_priority, research_priority * 1.3)
research_priority = int(research_priority)
print ""
print "Research Production (current/target) : ( %.1f / %.1f )" % (total_rp, target_rp)
print "Priority for Research: %d (new target ~ %d RP)" % (research_priority, total_pp * research_priority / industry_priority)
if len(enemies_sighted) < (2 + current_turn/20.0): # TODO: adjust for colonisation priority
research_priority *= 1.2
if (current_turn > 20) and (len(recent_enemies) > 3):
research_priority *= 0.8
return research_priority