本文整理匯總了Python中FleetUtilsAI.combine_ratings_list方法的典型用法代碼示例。如果您正苦於以下問題:Python FleetUtilsAI.combine_ratings_list方法的具體用法?Python FleetUtilsAI.combine_ratings_list怎麽用?Python FleetUtilsAI.combine_ratings_list使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類FleetUtilsAI
的用法示例。
在下文中一共展示了FleetUtilsAI.combine_ratings_list方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: assess_protection_focus
# 需要導入模塊: import FleetUtilsAI [as 別名]
# 或者: from FleetUtilsAI import combine_ratings_list [as 別名]
def assess_protection_focus(pid):
"""Return True if planet should use Protection Focus"""
this_planet = planetMap[pid]
sys_status = foAI.foAIstate.systemStatus.get(this_planet.systemID, {})
threat_from_supply = (0.25 * foAI.foAIstate.empire_standard_enemy_rating *
min(2, len(sys_status.get('enemies_nearly_supplied', []))))
print "Planet %s has regional+supply threat of %.1f" % ('P_%d<%s>'%(pid, this_planet.name), threat_from_supply)
regional_threat = sys_status.get('regional_threat', 0) + threat_from_supply
if not regional_threat: # no need for protection
if currentFocus[pid] == PFocus:
print "Advising dropping Protection Focus at %s due to no regional threat" % this_planet
return False
cur_prod_val = weighted_sum_output([currentOutput[pid][IFocus], currentOutput[pid][RFocus]])
target_prod_val = max(map(weighted_sum_output, [newTargets[pid][IFocus], newTargets[pid][RFocus]]))
prot_prod_val = weighted_sum_output(newTargets[pid][PFocus])
local_production_diff = 0.8 * cur_prod_val + 0.2 * target_prod_val - prot_prod_val
fleet_threat = sys_status.get('fleetThreat', 0)
# TODO: relax the below rejection once the overall determination of PFocus is better tuned
if not fleet_threat and local_production_diff > 8:
if currentFocus[pid] == PFocus:
print "Advising dropping Protection Focus at %s due to excessive productivity loss" % this_planet
return False
local_p_defenses = sys_status.get('mydefenses', {}).get('overall',0)
# TODO have adjusted_p_defenses take other in-system planets into account
adjusted_p_defenses = local_p_defenses * (1.0 if currentFocus[pid] != PFocus else 0.5)
local_fleet_rating = sys_status.get('myFleetRating', 0)
combined_local_defenses = sys_status.get('all_local_defenses', 0)
my_neighbor_rating = sys_status.get('my_neighbor_rating', 0)
neighbor_threat = sys_status.get('neighborThreat', 0)
safety_factor = 1.2 if currentFocus[pid] == PFocus else 0.5
cur_shield = this_planet.currentMeterValue(fo.meterType.shield)
max_shield = this_planet.currentMeterValue(fo.meterType.maxShield)
cur_troops = this_planet.currentMeterValue(fo.meterType.troops)
max_troops = this_planet.currentMeterValue(fo.meterType.maxTroops)
cur_defense = this_planet.currentMeterValue(fo.meterType.defense)
max_defense = this_planet.currentMeterValue(fo.meterType.maxDefense)
def_meter_pairs = [(cur_troops, max_troops), (cur_shield, max_shield), (cur_defense, max_defense)]
use_protection = True
reason = ""
if (fleet_threat and # i.e., an enemy is sitting on us
(currentFocus[pid] != PFocus or # too late to start protection TODO: but maybe regen worth it
# protection forcus only useful here if it maintains an elevated level
all([AIDependencies.PROT_FOCUS_MULTIPLIER * a <= b for a,b in def_meter_pairs]))):
use_protection = False
reason = "A"
elif ((currentFocus[pid] != PFocus and cur_shield < max_shield - 2 and
not tech_is_complete(AIDependencies.PLANET_BARRIER_I_TECH)) and
(cur_defense < max_defense - 2 and not tech_is_complete(AIDependencies.DEFENSE_REGEN_1_TECH)) and
(cur_troops < max_troops - 2)):
use_protection = False
reason = "B1"
elif ((currentFocus[pid] == PFocus and cur_shield*AIDependencies.PROT_FOCUS_MULTIPLIER < max_shield-2 and
not tech_is_complete(AIDependencies.PLANET_BARRIER_I_TECH)) and
(cur_defense*AIDependencies.PROT_FOCUS_MULTIPLIER < max_defense-2 and
not tech_is_complete(AIDependencies.DEFENSE_REGEN_1_TECH)) and
(cur_troops*AIDependencies.PROT_FOCUS_MULTIPLIER < max_troops-2)):
use_protection = False
reason = "B2"
elif max(max_shield, max_troops, max_defense) < 3: # joke defenses, don't bother with protection focus
use_protection = False
reason = "C"
elif regional_threat and local_production_diff <= 2.0:
reason = "D"
pass # i.e., use_protection = True
elif safety_factor * regional_threat <= local_fleet_rating:
use_protection = False
reason = "E"
elif (safety_factor * regional_threat <= combined_local_defenses and
(currentFocus[pid] != PFocus or
(0.5 * safety_factor * regional_threat <= local_fleet_rating and
fleet_threat == 0 and neighbor_threat < combined_local_defenses and
local_production_diff > 5))):
use_protection = False
reason = "F"
elif (regional_threat <= FleetUtilsAI.combine_ratings(local_fleet_rating, adjusted_p_defenses) and
safety_factor * regional_threat <=
FleetUtilsAI.combine_ratings_list([my_neighbor_rating, local_fleet_rating, adjusted_p_defenses]) and
local_production_diff > 5):
use_protection = False
reason = "G"
if use_protection or currentFocus[pid] == PFocus:
print ("Advising %sProtection Focus (reason %s) for planet %s, with local_prod_diff of %.1f, comb. local"
" defenses %.1f, local fleet rating %.1f and regional threat %.1f, threat sources: %s") % (
["dropping ", ""][use_protection], reason, this_planet, local_production_diff, combined_local_defenses,
local_fleet_rating, regional_threat, sys_status['regional_fleet_threats'])
return use_protection