condition
Owned city threatened
implemented owned_city_threat_score >= 0.7
backend/src/player_ai scores this from visible enemy heroes near owned cities and maps true to defend_home_city movement.
Strategic AI contract
Declarative utility profile from game_definition/ai/world_hero_ai.json, aligned with the current strategic world-map services without changing the Go runtime.
Profile
Declarative utility profile for an AI-controlled hero on the world map. The hero repeatedly spends movement points during its turn on discovered development goals: pickups, production sites, valuable guarded rewards, and exploration. Player hero attacks are opportunistic fallback actions, not the primary plan, and are suppressed while useful economy or exploration remains.
condition
owned_city_threat_score >= 0.7
backend/src/player_ai scores this from visible enemy heroes near owned cities and maps true to defend_home_city movement.
condition
hero_army_power_ratio < 0.65
backend/src/player_ai estimates hero army power from army slot counts and compares it with nearby visible enemy risk.
condition
stronger_visible_enemy_nearby == true
backend/src/player_ai considers discovered enemy heroes within local threat range and compares army slot power.
utility
evasion_hex_utility x
1 -> action_evade_to_safe_hex min 0.2 distance_from_threat + city_direction_bonus - distance_cost reinforce_city_utility x
0.9 -> action_reinforce_at_city min 0.15 garrison_value + safety_bonus - distance_cost backend/src/player_ai evaluates evasion and reinforce targets through this utility node.
condition
known_world_goal_available == true
backend/src/player_ai treats discovered pickups, production sites, and fallback player attacks as known goals; exploration remains the fallback when none exist.
condition
best_known_goal_blocked_by_neutral == true
True when a discovered neutral guards known nearby reward value and the AI has enough power to make the fight a utility candidate. The next utility node still compares it against safe pickups and production sites.
utility
guarded_resource_net_utility x
1.2 -> action_attack_neutral_for_reward min 0.35 unlocked_reward_value + blocker_unlock_bonus + urgency_bonus - distance_cost - battle_risk_cost; eligible only when unlocked_reward_value >= combat_policy.guarded_reward_thresholds.minimum_nearby_reward_value and score >= best_safe_score + safe_target_margin safe_resource_pickup_utility x
1 -> action_move_to_safe_resource min -1 reward_value + urgency_bonus - distance_cost safe_production_site_utility x
0.95 -> action_capture_safe_production_site min -1 production_value + urgency_bonus - distance_cost This is the risk-aware strategic choice: fight for discovered treasure behind discovered guards only when removing this specific guard unlocks clustered value and the guarded utility clearly beats safer known map goals.
utility
resource_pickup_utility x
1.15 -> action_move_to_safe_resource min -1 reward_value + urgency_bonus - distance_cost production_site_utility x
1 -> action_capture_safe_production_site min -1 production_value + urgency_bonus - distance_cost enemy_hero_attack_utility x
0.25 -> action_attack_player_hero min 0.85 enemy_value - distance_cost - battle_risk_cost - development_opportunity_cost Backend chooses among discovered development goals first. Player hero attack is allowed only after development and exploration have no positive target.
utility
frontier_reveal_utility x
1 -> action_scout_frontier min 0.15 unknown_tiles_revealed + route_branching_bonus - distance_cost - local_risk_cost safe_frontier_utility x
0.8 -> action_scout_frontier min 0.1 unknown_tiles_revealed - distance_cost - local_risk_cost Exploration is the fallback when no discovered reward has positive net utility, and it still takes priority over hunting weaker player heroes.
action
defend_home_city
backend/src/player_ai emits move-hero toward an owned city footprint when a visible enemy threatens it.
action
reinforce_at_city
backend/src/player_ai currently emits move-hero toward the nearest owned city; future city-garrison transfer can be appended when that command exists in the event-sourced backend.
action
evade_to_safe_hex
backend/src/player_ai emits move-hero toward the best discovered safe hex.
action
attack_neutral_for_reward
backend/src/player_ai emits start-battle with sourceType neutral, mobId, and a neutral battle preview after moving adjacent to the exact neutral that unlocks the best known reward cluster.
action
move_to_resource
backend/src/player_ai classifies collectible pickups from game_definition/map_objects/objects.json metadata and emits move-hero plus collect-pickup commands.
action
capture-production-site
backend/src/player_ai classifies capturable production sites from game_definition/map_objects/objects.json metadata and emits move-hero plus capture-production-site commands.
action
attack_player_hero
backend/src/player_ai emits start-battle against a weaker discovered player hero only when pickup, production-site, and exploration targets are unavailable.
action
scout_frontier
backend/src/player_ai chooses exploration as a development fallback and emits move-hero commands toward discovered frontier tiles.
action
wait
backend/src/player_ai returns Strategy: wait when no target is selected.