AI_record_score = { set_temp_variable_to_random = { var = state_randomizer min = -15 max = 15 integer = yes } add_to_temp_variable = { AI_score = state_randomizer } if = { limit = { check_variable = { AI_score > AI_best_score } } set_temp_variable = { AI_best_score = AI_score } set_temp_variable = { AI_best_target = THIS.id } set_temp_variable = { AI_best_type = AI_score_type } } } invest_cic = { ROOT = { set_variable = { project_building_type^-1 = 1 } set_variable = { project_build_amount^-1 = 1 } update_gui = yes PREV = { CONTROLLER = { send_pending_investment_offer = yes } } } } invest_mic = { ROOT = { set_variable = { project_building_type^-1 = 2 } set_variable = { project_build_amount^-1 = 1 } update_gui = yes PREV = { CONTROLLER = { send_pending_investment_offer = yes } } } } invest_infra = { ROOT = { set_variable = { project_building_type^-1 = 4 } set_variable = { project_build_amount^-1 = 1 } update_gui = yes PREV = { CONTROLLER = { send_pending_investment_offer = yes } } } } # Building Type 1: Civilian industry AI_get_civilian_industry_score = { if = { limit = { free_building_slots = { building = industrial_complex size > 0 include_locked = no } } set_temp_variable = { AI_score = 0 } set_temp_variable = { v1 = 170 } if = { limit = { check_variable = { tgt_civs_to_factories_ratio < 0.65 } } add_to_temp_variable = { v1 = 15 } } set_temp_variable = { v2 = building_level@industrial_complex } multiply_temp_variable = { v2 = 25 } set_temp_variable = { pending_penalty = pending_civs } multiply_temp_variable = { pending_penalty = 40 } add_to_temp_variable = { v2 = pending_penalty } if = { limit = { check_variable = { tgt_avail_civs > 15 } } add_to_temp_variable = { v2 = 5 } } if = { limit = { check_variable = { tgt_avail_civs > 30 } } add_to_temp_variable = { v2 = 10 } } if = { limit = { check_variable = { tgt_avail_civs > 45 } } add_to_temp_variable = { v2 = 15 } } if = { limit = { check_variable = { tgt_unemployment < 0.020 } check_variable = { tgt_pop_m < 30 } } add_to_temp_variable = { v2 = 100 } } if = { limit = { check_variable = { tgt_unemployment < 0.010 } check_variable = { tgt_pop_m > 29.999 } } add_to_temp_variable = { v2 = 100 } } if = { limit = { check_variable = { pending_shared_slot_building > 0 } } add_to_temp_variable = { v2 = 15 } } subtract_from_temp_variable = { v1 = v2 } add_to_temp_variable = { AI_score = v1 } set_temp_variable = { AI_score_type = 1 } AI_record_score = yes } } # Building Type 2: Military Industry AI_get_military_industry_score = { if = { limit = { free_building_slots = { building = arms_factory size > 0 include_locked = no } } set_temp_variable = { AI_score = 0 } set_temp_variable = { v1 = 150 } # Increase Section if = { limit = { date > 2004.1.1 } add_to_temp_variable = { v1 = 10 } } if = { limit = { date > 2006.1.1 } add_to_temp_variable = { v1 = 10 } } if = { limit = { threat > 0.1 } add_to_temp_variable = { v1 = 10 } } if = { limit = { threat > 0.2 } add_to_temp_variable = { v1 = 10 } } if = { limit = { threat > 0.4 } add_to_temp_variable = { v1 = 10 } } if = { limit = { check_variable = { tgt_num_mils < 15 } } add_to_temp_variable = { v1 = 10 } } if = { limit = { check_variable = { tgt_num_mils < 10 } } add_to_temp_variable = { v1 = 10 } } if = { limit = { check_variable = { tgt_num_mils < 5 } } add_to_temp_variable = { v1 = 10 } } if = { limit = { check_variable = { tgt_AI_threatened = 1 } } add_to_temp_variable = { v1 = 15 } } set_temp_variable = { v2 = building_level@arms_factory } multiply_temp_variable = { v2 = 25 } set_temp_variable = { pending_penalty = pending_mils } multiply_temp_variable = { pending_penalty = 40 } add_to_temp_variable = { v2 = pending_penalty } if = { limit = { check_variable = { tgt_has_war = 0 } } add_to_temp_variable = { v2 = 20 } } if = { limit = { check_variable = { tgt_avail_civs < 15 } } add_to_temp_variable = { v2 = 10 } } if = { limit = { check_variable = { tgt_avail_civs < 10 } } add_to_temp_variable = { v2 = 10 } } if = { limit = { check_variable = { tgt_avail_civs < 5 } } add_to_temp_variable = { v2 = 10 } } if = { limit = { check_variable = { tgt_mils_to_factories_ratio > 0.45 } } add_to_temp_variable = { v2 = 70 } } if = { limit = { check_variable = { pending_shared_slot_building > 0 } } add_to_temp_variable = { v2 = 15 } } if = { limit = { check_variable = { tgt_unemployment < 0.001 } } add_to_temp_variable = { v2 = 50 } } subtract_from_temp_variable = { v1 = v2 } add_to_temp_variable = { AI_score = v1 } set_temp_variable = { AI_score_type = 2 } AI_record_score = yes } } # Building Type 3: Dockyards AI_get_dockyard_score = { if = { limit = { free_building_slots = { building = dockyard size > 0 include_locked = no } } set_temp_variable = { AI_score = 0 } set_temp_variable = { v1 = 170 } if = { limit = { check_variable = { tgt_num_naval < 15 } } add_to_temp_variable = { v1 = 10 } } if = { limit = { check_variable = { tgt_num_naval < 10 } } add_to_temp_variable = { v1 = 10 } } if = { limit = { check_variable = { tgt_num_naval < 5 } } add_to_temp_variable = { v1 = 10 } } if = { limit = { check_variable = { tgt_AI_threatened = 1 } } add_to_temp_variable = { v1 = 15 } } set_temp_variable = { v2 = building_level@dockyard } multiply_temp_variable = { v2 = 25 } set_temp_variable = { pending_penalty = pending_docks } multiply_temp_variable = { pending_penalty = 40 } add_to_temp_variable = { v2 = pending_penalty } if = { limit = { check_variable = { tgt_has_war = 0 } } add_to_temp_variable = { v2 = 35 } } if = { limit = { is_coastal = no } add_to_temp_variable = { v2 = 100 } } if = { limit = { check_variable = { tgt_steel_produced < 200 } } add_to_temp_variable = { v2 = 20 } } if = { limit = { check_variable = { tgt_steel_produced < 100 } } add_to_temp_variable = { v2 = 40 } } if = { limit = { check_variable = { tgt_gdp_total < 1000 } } add_to_temp_variable = { v2 = 100 } } if = { limit = { check_variable = { tgt_interest_rate > 10.5 } } add_to_temp_variable = { v2 = 40 } } if = { limit = { check_variable = { tgt_num_factories > 0 } } set_temp_variable = { docks_to_factories_ratio = tgt_num_naval } divide_temp_variable = { docks_to_factories_ratio = tgt_num_factories } if = { limit = { check_variable = { docks_to_factories_ratio > 0.20 } } add_to_temp_variable = { v2 = 50 } } } if = { limit = { check_variable = { tgt_unemployment < 0.001 } } add_to_temp_variable = { v2 = 50 } } if = { limit = { check_variable = { pending_shared_slot_building > 0 } } add_to_temp_variable = { v2 = 15 } } subtract_from_temp_variable = { v1 = v2 } add_to_temp_variable = { AI_score = v1 } set_temp_variable = { AI_score_type = 3 } AI_record_score = yes } } # Building Type 4: Infrastructure AI_get_infrastructure_score = { if = { limit = { free_building_slots = { building = infrastructure size > 0 include_locked = no } } set_temp_variable = { AI_score = 0 } set_temp_variable = { v1 = 175 } if = { limit = { OR = { has_resources_amount = { resource = aluminium amount > 10 } has_resources_amount = { resource = oil amount > 10 } has_resources_amount = { resource = steel amount > 10 } has_resources_amount = { resource = rubber amount > 10 } has_resources_amount = { resource = tungsten amount > 10 } has_resources_amount = { resource = chromium amount > 10 } } } add_to_temp_variable = { v1 = 25 } } if = { limit = { OR = { has_resources_amount = { resource = aluminium amount > 20 } has_resources_amount = { resource = oil amount > 20 } has_resources_amount = { resource = steel amount > 20 } has_resources_amount = { resource = rubber amount > 20 } has_resources_amount = { resource = tungsten amount > 20 } has_resources_amount = { resource = chromium amount > 20 } } } add_to_temp_variable = { v1 = 25 } } set_temp_variable = { v2 = building_level@infrastructure } multiply_temp_variable = { v2 = 20 } if = { limit = { free_building_slots = { building = industrial_complex size < 2 include_locked = no } } add_to_temp_variable = { v2 = 15 } } if = { limit = { free_building_slots = { building = industrial_complex size < 5 include_locked = no } } add_to_temp_variable = { v2 = 15 } } if = { limit = { free_building_slots = { building = industrial_complex size < 10 include_locked = no } } add_to_temp_variable = { v2 = 15 } } set_temp_variable = { differential_infra = building_level@infrastructure } add_to_temp_variable = { differential_infra = pending_infra } if = { limit = { check_variable = { building_level@infrastructure = 5 } } multiply_temp_variable = { AI_score = 0 } } else_if = { limit = { check_variable = { differential_infra > 4.999 } } multiply_temp_variable = { AI_score = 0 } } else = { add_to_temp_variable = { differential_infra = remaining_level } if = { limit = { check_variable = { differential_infra > 4 } } add_to_temp_variable = { v2 = 100 } } subtract_from_temp_variable = { v1 = v2 } add_to_temp_variable = { AI_score = v1 } } set_temp_variable = { AI_score_type = 4 } AI_record_score = yes } } # Building Type 5: Offices AI_get_offices_score = { if = { limit = { free_building_slots = { building = offices size > 0 include_locked = no } } set_temp_variable = { AI_score = 0 } set_temp_variable = { v1 = 180 } if = { limit = { check_variable = { tgt_corp_tax > 22 } } add_to_temp_variable = { v1 = 10 } } if = { limit = { check_variable = { tgt_corp_tax > 27 } } add_to_temp_variable = { v1 = 15 } } if = { limit = { check_variable = { tgt_corp_tax > 32 } } add_to_temp_variable = { v1 = 20 } } set_temp_variable = { v2 = building_level@offices } multiply_temp_variable = { v2 = 25 } set_temp_variable = { pending_penalty = pending_offices } multiply_temp_variable = { pending_penalty = 40 } add_to_temp_variable = { v2 = pending_penalty } if = { limit = { check_variable = { tgt_avail_civs < 1 } } add_to_temp_variable = { v2 = 15 } } if = { limit = { check_variable = { tgt_avail_civs < 5 } } add_to_temp_variable = { v2 = 12 } } if = { limit = { check_variable = { tgt_avail_civs < 10 } } add_to_temp_variable = { v2 = 8 } } if = { limit = { check_variable = { tgt_avail_civs < 15 } } add_to_temp_variable = { v2 = 5 } } if = { limit = { check_variable = { tgt_gdp_per_capita < 15 } } add_to_temp_variable = { v2 = 15 } } if = { limit = { check_variable = { tgt_unemployment < 0.020 } check_variable = { tgt_pop_m < 30 } } add_to_temp_variable = { v2 = 100 } } if = { limit = { check_variable = { tgt_unemployment < 0.010 } check_variable = { tgt_pop_m > 29.999 } } add_to_temp_variable = { v2 = 100 } } if = { limit = { check_variable = { pending_shared_slot_building > 0 } } add_to_temp_variable = { v2 = 15 } } subtract_from_temp_variable = { v1 = v2 } add_to_temp_variable = { AI_score = v1 } set_temp_variable = { AI_score_type = 5 } AI_record_score = yes } } AI_count_pending_projects = { set_temp_variable = { pending_civs = 0 } set_temp_variable = { pending_mils = 0 } set_temp_variable = { pending_docks = 0 } set_temp_variable = { pending_offices = 0 } set_temp_variable = { pending_antiair = 0 } set_temp_variable = { pending_radar = 0 } set_temp_variable = { pending_airbases = 0 } set_temp_variable = { pending_fuel_silos = 0 } set_temp_variable = { pending_internet = 0 } set_temp_variable = { pending_infra = 0 } set_temp_variable = { pending_shared_slot_building = 0 } for_each_loop = { array = project_type_in_state value = v index = i if = { limit = { check_variable = { project_type_in_state^i = 1 } } add_to_temp_variable = { pending_civs = 1 } add_to_temp_variable = { pending_shared_slot_building = 1 } } else_if = { limit = { check_variable = { project_type_in_state^i = 2 } } add_to_temp_variable = { pending_mils = 1 } add_to_temp_variable = { pending_shared_slot_building = 1 } } else_if = { limit = { check_variable = { project_type_in_state^i = 3 } } add_to_temp_variable = { pending_docks = 1 } add_to_temp_variable = { pending_shared_slot_building = 1 } } else_if = { limit = { check_variable = { project_type_in_state^i = 4 } } add_to_temp_variable = { pending_infra = 1 } } else_if = { limit = { check_variable = { project_type_in_state^i = 5 } } add_to_temp_variable = { pending_offices = 1 } add_to_temp_variable = { pending_shared_slot_building = 1 } } else_if = { limit = { check_variable = { project_type_in_state^i = 6 } } add_to_temp_variable = { pending_antiair = 1 } } else_if = { limit = { check_variable = { project_type_in_state^i = 7 } } add_to_temp_variable = { pending_radar = 1 } } else_if = { limit = { check_variable = { project_type_in_state^i = 8 } } add_to_temp_variable = { pending_airbases = 1 } } else_if = { limit = { check_variable = { project_type_in_state^i = 9 } } add_to_temp_variable = { pending_fuel_silos = 1 } } else_if = { limit = { check_variable = { project_type_in_state^i = 10 } } add_to_temp_variable = { pending_internet = 1 } } } } # Building Type 6: Surface to Air Missiles (SAM/Antiair) AI_get_antiair_score = { if = { limit = { free_building_slots = { building = anti_air_building size > 0 include_locked = no } } set_temp_variable = { AI_score = 0 } set_temp_variable = { v1 = 120 } if = { limit = { threat > 0.1 } add_to_temp_variable = { v1 = 15 } } if = { limit = { threat > 0.25 } add_to_temp_variable = { v1 = 20 } } if = { limit = { threat > 0.5 } add_to_temp_variable = { v1 = 25 } } if = { limit = { check_variable = { tgt_has_war = 1 } } add_to_temp_variable = { v1 = 40 } } if = { limit = { check_variable = { tgt_AI_threatened = 1 } } add_to_temp_variable = { v1 = 25 } } if = { limit = { check_variable = { tgt_neighbor_at_war = 1 } } add_to_temp_variable = { v1 = 30 } } if = { limit = { is_coastal = yes } add_to_temp_variable = { v1 = 10 } } if = { limit = { is_capital = yes } add_to_temp_variable = { v1 = 15 } } set_temp_variable = { v2 = building_level@anti_air_building } multiply_temp_variable = { v2 = 30 } set_temp_variable = { pending_penalty = pending_antiair } multiply_temp_variable = { pending_penalty = 45 } add_to_temp_variable = { v2 = pending_penalty } if = { limit = { check_variable = { tgt_has_war = 0 } check_variable = { tgt_threat < 0.5 } } add_to_temp_variable = { v2 = 50 } } if = { limit = { check_variable = { tgt_avail_civs < 10 } } add_to_temp_variable = { v2 = 30 } } subtract_from_temp_variable = { v1 = v2 } add_to_temp_variable = { AI_score = v1 } set_temp_variable = { AI_score_type = 6 } AI_record_score = yes } } # Building Type 7: Radar Stations AI_get_radar_score = { if = { limit = { free_building_slots = { building = radar_station size > 0 include_locked = no } } set_temp_variable = { AI_score = 0 } set_temp_variable = { v1 = 115 } if = { limit = { threat > 0.1 } add_to_temp_variable = { v1 = 15 } } if = { limit = { threat > 0.25 } add_to_temp_variable = { v1 = 20 } } if = { limit = { threat > 0.5 } add_to_temp_variable = { v1 = 25 } } if = { limit = { check_variable = { tgt_has_war = 1 } } add_to_temp_variable = { v1 = 35 } } if = { limit = { check_variable = { tgt_AI_threatened = 1 } } add_to_temp_variable = { v1 = 20 } } if = { limit = { is_coastal = yes } add_to_temp_variable = { v1 = 20 } } if = { limit = { is_capital = yes } add_to_temp_variable = { v1 = 15 } } if = { limit = { check_variable = { tgt_has_maritime_industry = 1 } is_coastal = yes } add_to_temp_variable = { v1 = 15 } } set_temp_variable = { v2 = building_level@radar_station } multiply_temp_variable = { v2 = 35 } set_temp_variable = { pending_penalty = pending_radar } multiply_temp_variable = { pending_penalty = 45 } add_to_temp_variable = { v2 = pending_penalty } if = { limit = { check_variable = { tgt_has_war = 0 } check_variable = { tgt_threat < 0.5 } } add_to_temp_variable = { v2 = 45 } } if = { limit = { check_variable = { tgt_avail_civs < 10 } } add_to_temp_variable = { v2 = 25 } } subtract_from_temp_variable = { v1 = v2 } add_to_temp_variable = { AI_score = v1 } set_temp_variable = { AI_score_type = 7 } AI_record_score = yes } } # Building Type 8: Air Bases AI_get_airbase_score = { if = { limit = { free_building_slots = { building = air_base size > 0 include_locked = no } } set_temp_variable = { AI_score = 0 } set_temp_variable = { v1 = 130 } if = { limit = { check_variable = { tgt_has_war = 1 } } add_to_temp_variable = { v1 = 40 } } if = { limit = { check_variable = { tgt_AI_threatened = 1 } } add_to_temp_variable = { v1 = 25 } } if = { limit = { threat > 0.15 } add_to_temp_variable = { v1 = 15 } } if = { limit = { threat > 0.3 } add_to_temp_variable = { v1 = 15 } } if = { limit = { threat > 0.5 } add_to_temp_variable = { v1 = 20 } } if = { limit = { is_coastal = yes } add_to_temp_variable = { v1 = 15 } } if = { limit = { is_capital = yes } add_to_temp_variable = { v1 = 10 } } if = { limit = { check_variable = { tgt_num_mils > 20 } } add_to_temp_variable = { v1 = 10 } } set_temp_variable = { v2 = building_level@air_base } multiply_temp_variable = { v2 = 25 } set_temp_variable = { pending_penalty = pending_airbases } multiply_temp_variable = { pending_penalty = 40 } add_to_temp_variable = { v2 = pending_penalty } if = { limit = { check_variable = { tgt_has_war = 0 } } add_to_temp_variable = { v2 = 30 } } if = { limit = { check_variable = { tgt_avail_civs < 15 } } add_to_temp_variable = { v2 = 20 } } if = { limit = { check_variable = { tgt_avail_civs < 10 } } add_to_temp_variable = { v2 = 30 } } if = { limit = { check_variable = { tgt_max_fuel < 100 } } add_to_temp_variable = { v2 = 40 } } subtract_from_temp_variable = { v1 = v2 } add_to_temp_variable = { AI_score = v1 } set_temp_variable = { AI_score_type = 8 } AI_record_score = yes } } # Building Type 9: Fuel Silo AI_get_fuel_silo_score = { if = { limit = { free_building_slots = { building = fuel_silo size > 0 include_locked = no } } set_temp_variable = { AI_score = 0 } set_temp_variable = { v1 = 140 } if = { limit = { check_variable = { tgt_has_war = 1 } } add_to_temp_variable = { v1 = 40 } } if = { limit = { check_variable = { tgt_neighbor_at_war = 1 } } add_to_temp_variable = { v1 = 30 } } if = { limit = { check_variable = { tgt_AI_threatened = 1 } } add_to_temp_variable = { v1 = 20 } } if = { limit = { check_variable = { tgt_max_fuel < 250 } } add_to_temp_variable = { v1 = 30 } } if = { limit = { check_variable = { tgt_max_fuel < 500 } } add_to_temp_variable = { v1 = 20 } } if = { limit = { check_variable = { tgt_max_fuel < 750 } } add_to_temp_variable = { v1 = 15 } } if = { limit = { check_variable = { tgt_num_mils > 20 } } add_to_temp_variable = { v1 = 15 } } if = { limit = { check_variable = { tgt_num_mils > 40 } } add_to_temp_variable = { v1 = 15 } } if = { limit = { is_coastal = yes } add_to_temp_variable = { v1 = 10 } } set_temp_variable = { v2 = 0 } set_temp_variable = { existing_silos = building_level@fuel_silo } multiply_temp_variable = { existing_silos = 30 } add_to_temp_variable = { v2 = existing_silos } set_temp_variable = { pending_penalty = pending_fuel_silos } multiply_temp_variable = { pending_penalty = 40 } add_to_temp_variable = { v2 = pending_penalty } if = { limit = { check_variable = { tgt_max_fuel > 1500 } } add_to_temp_variable = { v2 = 40 } } if = { limit = { check_variable = { tgt_max_fuel > 2500 } } add_to_temp_variable = { v2 = 60 } } if = { limit = { check_variable = { tgt_has_war = 0 } check_variable = { tgt_threat < 0.1 } } add_to_temp_variable = { v2 = 30 } } if = { limit = { check_variable = { tgt_avail_civs < 10 } } add_to_temp_variable = { v2 = 25 } } subtract_from_temp_variable = { v1 = v2 } add_to_temp_variable = { AI_score = v1 } set_temp_variable = { AI_score_type = 9 } AI_record_score = yes } } # Building Type 10: Network Infrastructure AI_get_network_infrastructure_score = { if = { limit = { free_building_slots = { building = internet_station size > 0 include_locked = no } } set_temp_variable = { AI_score = 0 } set_temp_variable = { v1 = 125 } if = { limit = { check_variable = { building_level@infrastructure = 5 } } add_to_temp_variable = { v1 = 50 } } if = { limit = { check_variable = { THIS.state_population_k > 100 } } add_to_temp_variable = { v1 = 5 } } if = { limit = { check_variable = { THIS.state_population_k > 500 } } add_to_temp_variable = { v1 = 10 } } if = { limit = { check_variable = { THIS.state_population_k > 1000 } } add_to_temp_variable = { v1 = 10 } } if = { limit = { check_variable = { THIS.state_population_k > 2000 } } add_to_temp_variable = { v1 = 10 } } if = { limit = { check_variable = { THIS.state_population_k > 4000 } } add_to_temp_variable = { v1 = 10 } } if = { limit = { check_variable = { THIS.state_population_k > 6000 } } add_to_temp_variable = { v1 = 15 } } if = { limit = { check_variable = { tgt_gdp_per_capita > 20 } } add_to_temp_variable = { v1 = 15 } } if = { limit = { check_variable = { tgt_gdp_per_capita > 30 } } add_to_temp_variable = { v1 = 10 } } set_temp_variable = { v2 = 0 } set_temp_variable = { existing_internet = building_level@internet_station } multiply_temp_variable = { existing_internet = 25 } add_to_temp_variable = { v2 = existing_internet } set_temp_variable = { pending_penalty = pending_internet } multiply_temp_variable = { pending_penalty = 40 } add_to_temp_variable = { v2 = pending_penalty } # Poor countries can't afford/utilize it if = { limit = { check_variable = { tgt_gdp_per_capita < 9.999 } } add_to_temp_variable = { v2 = 50 } } if = { limit = { check_variable = { tgt_gdp_per_capita < 5.000 } } add_to_temp_variable = { v2 = 100 } } subtract_from_temp_variable = { v1 = v2 } add_to_temp_variable = { AI_score = v1 } set_temp_variable = { AI_score_type = 10 } AI_record_score = yes } } # Building Type 11: Renewable Energy Infrastructure AI_get_renewable_energy_score = { if = { limit = { free_building_slots = { building = renewable_energy_infra size > 0 include_locked = no } } set_temp_variable = { AI_score = 0 } set_temp_variable = { v1 = 100 } if = { limit = { check_variable = { energy_balance_ratio < 1.00 } } add_to_temp_variable = { v1 = 5 } } if = { limit = { check_variable = { energy_balance_ratio < 0.95 } } add_to_temp_variable = { v1 = 10 } } if = { limit = { check_variable = { energy_balance_ratio < 0.90 } } add_to_temp_variable = { v1 = 15 } } if = { limit = { check_variable = { energy_balance_ratio < 0.85 } } add_to_temp_variable = { v1 = 20 } } if = { limit = { check_variable = { energy_balance_ratio < 0.80 } } add_to_temp_variable = { v1 = 25 } } if = { limit = { check_variable = { energy_balance_ratio < 0.70 } } add_to_temp_variable = { v1 = 30 } } set_temp_variable = { state_renewable_capacity_factor_score = modifier@state_renewable_capacity_factor_modifier } multiply_temp_variable = { state_renewable_capacity_factor_score = 64 } # ~ capacity factor * 175 (factor averages 1) add_to_temp_variable = { v1 = state_renewable_capacity_factor_score } set_temp_variable = { renewable_energy_gain_multiplier_score = tgt_renewable_mult } multiply_temp_variable = { renewable_energy_gain_multiplier_score = 20 } add_to_temp_variable = { v1 = renewable_energy_gain_multiplier_score } if = { limit = { check_variable = { tgt_oil_imported > 0 } } add_to_temp_variable = { v1 = 30 } } set_temp_variable = { v2 = 0 } if = { limit = { check_variable = { tgt_renewable_mult < 1.50 } } add_to_temp_variable = { v2 = 1000 } } if = { limit = { check_variable = { energy_balance_ratio > 1.25 } } add_to_temp_variable = { v2 = 1000 } } subtract_from_temp_variable = { v1 = v2 } add_to_temp_variable = { AI_score = v1 } set_temp_variable = { AI_score_type = 11 } AI_record_score = yes } } # Building Type 12: Fossil Fuel Powerplant AI_get_fossil_powerplant_score = { if = { limit = { free_building_slots = { building = fossil_powerplant size > 0 include_locked = no } } set_temp_variable = { AI_score = 0 } set_temp_variable = { v1 = 95 } if = { limit = { check_variable = { energy_balance_ratio < 1.00 } } add_to_temp_variable = { v1 = 10 } } if = { limit = { check_variable = { energy_balance_ratio < 0.95 } } add_to_temp_variable = { v1 = 15 } } if = { limit = { check_variable = { energy_balance_ratio < 0.90 } } add_to_temp_variable = { v1 = 20 } } if = { limit = { check_variable = { energy_balance_ratio < 0.85 } } add_to_temp_variable = { v1 = 25 } } if = { limit = { check_variable = { energy_balance_ratio < 0.80 } } add_to_temp_variable = { v1 = 30 } } if = { limit = { check_variable = { energy_balance_ratio < 0.70 } } add_to_temp_variable = { v1 = 40 } } if = { limit = { check_variable = { tgt_idea_heavy_power_restrict = 1 } } add_to_temp_variable = { v1 = 10 } } if = { limit = { check_variable = { tgt_idea_some_power_restrict = 1 } } add_to_temp_variable = { v1 = 5 } } if = { limit = { check_variable = { tgt_idea_heavy_consumption = 1 } } add_to_temp_variable = { v1 = -25 } } if = { limit = { check_variable = { tgt_idea_some_consumption = 1 } } add_to_temp_variable = { v1 = -15 } } add_to_temp_variable = { AI_score = v1 } set_temp_variable = { AI_score_type = 12 } AI_record_score = yes } } # Building Type 13: Nuclear Reactor # Reactor-policy check hoisted to caller as tgt_can_build_reactors (ideas don't change mid-loop). AI_get_nuclear_reactor_score = { if = { limit = { free_building_slots = { building = nuclear_reactor size > 0 include_locked = no } } set_temp_variable = { AI_score = 0 } set_temp_variable = { v1 = 110 } if = { limit = { check_variable = { energy_balance_ratio < 1.00 } } add_to_temp_variable = { v1 = 15 } } if = { limit = { check_variable = { energy_balance_ratio < 0.95 } } add_to_temp_variable = { v1 = 20 } } if = { limit = { check_variable = { energy_balance_ratio < 0.90 } } add_to_temp_variable = { v1 = 25 } } if = { limit = { check_variable = { energy_balance_ratio < 0.85 } } add_to_temp_variable = { v1 = 30 } } if = { limit = { check_variable = { energy_balance_ratio < 0.80 } } add_to_temp_variable = { v1 = 35 } } if = { limit = { check_variable = { energy_balance_ratio < 0.70 } } add_to_temp_variable = { v1 = 45 } } if = { limit = { check_variable = { tgt_gdp_per_capita > 25 } } add_to_temp_variable = { v1 = 20 } } if = { limit = { check_variable = { tgt_gdp_per_capita > 35 } } add_to_temp_variable = { v1 = 15 } } if = { limit = { check_variable = { tgt_gdp_per_capita > 45 } } add_to_temp_variable = { v1 = 10 } } if = { limit = { check_variable = { THIS.state_population_k > 2000 } } add_to_temp_variable = { v1 = 15 } } if = { limit = { check_variable = { THIS.state_population_k > 4000 } } add_to_temp_variable = { v1 = 15 } } if = { limit = { check_variable = { THIS.state_population_k > 6000 } } add_to_temp_variable = { v1 = 10 } } if = { limit = { check_variable = { tgt_oil_imported > 0 } } add_to_temp_variable = { v1 = 25 } } if = { limit = { check_variable = { tgt_idea_heavy_power_restrict = 1 } } add_to_temp_variable = { v1 = 30 } } if = { limit = { check_variable = { tgt_idea_some_power_restrict = 1 } } add_to_temp_variable = { v1 = 15 } } set_temp_variable = { v2 = 0 } if = { limit = { check_variable = { tgt_gdp_per_capita < 20 } } add_to_temp_variable = { v2 = 100 } } if = { limit = { check_variable = { tgt_gdp_total < 500 } } add_to_temp_variable = { v2 = 75 } } if = { limit = { check_variable = { tgt_interest_rate > 10.5 } } add_to_temp_variable = { v2 = 60 } } if = { limit = { check_variable = { tgt_interest_rate > 8.5 } } add_to_temp_variable = { v2 = 40 } } if = { limit = { check_variable = { energy_balance_ratio > 1.15 } } add_to_temp_variable = { v2 = 1000 } } set_temp_variable = { existing_reactors = building_level@nuclear_reactor } multiply_temp_variable = { existing_reactors = 50 } add_to_temp_variable = { v2 = existing_reactors } if = { limit = { check_variable = { tgt_idea_heavy_consumption = 1 } } add_to_temp_variable = { v2 = 30 } } if = { limit = { check_variable = { tgt_idea_some_consumption = 1 } } add_to_temp_variable = { v2 = 20 } } subtract_from_temp_variable = { v1 = v2 } add_to_temp_variable = { AI_score = v1 } set_temp_variable = { AI_score_type = 13 } AI_record_score = yes } } AI_edge_case_calculations = { if = { limit = { check_variable = { THIS.state_population_k < 100 } } subtract_from_temp_variable = { AI_score = 20 } } if = { limit = { check_variable = { THIS.state_population_k < 85 } } subtract_from_temp_variable = { AI_score = 40 } } if = { limit = { check_variable = { THIS.state_population_k < 60 } } subtract_from_temp_variable = { AI_score = 80 } } if = { limit = { has_state_flag = currently_encouraged_investments } add_to_temp_variable = { AI_score = 20 } } if = { limit = { has_state_flag = HOL_autonomy_economic_zone } add_to_temp_variable = { AI_score = 20 } } if = { limit = { has_state_flag = ENG_found_invest_northern_ireland_active } add_to_temp_variable = { AI_score = 20 } } } AI_country_selection_calculation = { if = { limit = { has_idea = non_state_actor } add_to_temp_variable = { AI_country_score = -60 } } if = { limit = { has_country_flag = recently_refused_investment@PREV } add_to_temp_variable = { AI_country_score = -100 } } if = { limit = { has_country_flag = recently_accepted_an_investment } add_to_temp_variable = { AI_country_score = -50 } } if = { limit = { is_in_faction_with = PREV } add_to_temp_variable = { AI_country_score = 25 } } if = { limit = { has_country_flag = trade_agreement@PREV } add_to_temp_variable = { AI_country_score = 25 } } if = { limit = { has_country_flag = mutual_investment_treaty_@PREV } add_to_temp_variable = { AI_country_score = 25 } } if = { limit = { PREV = { check_variable = { active_projects > 0 } } } PREV = { for_each_loop = { array = project_array value = v index = i if = { limit = { check_variable = { v < 0 } check_variable = { project_target_country^i = PREV.id } } add_to_temp_variable = { AI_country_score = -35 } } } } } if = { limit = { has_idea = EU_member } if = { limit = { check_variable = { inv_has_ECB_president = 1 } } add_to_temp_variable = { AI_country_score = 15 } } if = { limit = { check_variable = { inv_has_EU_finance_minister = 1 } } add_to_temp_variable = { AI_country_score = 5 } } } if = { limit = { is_in_array = { array = influence_array value = PREV.id } } add_to_temp_variable = { AI_country_score = 40 } } if = { limit = { PREV = { is_in_array = { array = influence_array value = PREV.id } } } add_to_temp_variable = { AI_country_score = 40 } } set_temp_variable = { opinion_value = opinion@PREV } multiply_temp_variable = { opinion_value = 0.30 } clamp_temp_variable = { var = opinion_value min = -75 max = 75 } add_to_temp_variable = { AI_country_score = opinion_value } if = { limit = { has_idea = corruption_level_10 } add_to_temp_variable = { AI_country_score = -25 } } else_if = { limit = { has_idea = corruption_level_09 } add_to_temp_variable = { AI_country_score = -20 } } else_if = { limit = { has_idea = corruption_level_08 } add_to_temp_variable = { AI_country_score = -17.5 } } else_if = { limit = { has_idea = corruption_level_07 } add_to_temp_variable = { AI_country_score = -15 } } else_if = { limit = { has_idea = corruption_level_06 } add_to_temp_variable = { AI_country_score = -12.5 } } else_if = { limit = { has_idea = corruption_level_05 } add_to_temp_variable = { AI_country_score = -10 } } else_if = { limit = { has_idea = corruption_level_04 } add_to_temp_variable = { AI_country_score = -7.5 } } else_if = { limit = { has_idea = corruption_level_03 } add_to_temp_variable = { AI_country_score = -5 } } else_if = { limit = { has_idea = corruption_level_02 } add_to_temp_variable = { AI_country_score = -2 } } # Corporate Tax Evaluation if = { limit = { check_variable = { corporate_tax_rate > 30 } } set_temp_variable = { corp_temp = corporate_tax_rate } multiply_temp_variable = { corp_temp = -0.50 } add_to_temp_variable = { AI_country_score = corp_temp } } if = { limit = { country_exists = PREV is_on_same_continent_as = PREV } add_to_temp_variable = { AI_country_score = 25 } } # Countries under 30k gdpc will receive a bonus to score of 1.5 per gdcp under 30k and ones above will receive a score reduction for the same amount. set_temp_variable = { gdpc_scaler = gdp_per_capita } multiply_temp_variable = { gdpc_scaler = -2 } add_to_temp_variable = { gdpc_scaler = 60 } add_to_temp_variable = { AI_country_score = gdpc_scaler } # Countries with big economies slightly less likely to get investments, mostly to slightly reduce the mass amount of investments going into developed European countries set_temp_variable = { gdp_scaler = gdp_total } multiply_temp_variable = { gdp_scaler = -0.002 } clamp_temp_variable = { var = gdp_scaler min = -20 } add_to_temp_variable = { AI_country_score = gdp_scaler } # if = { # limit = { check_variable = { gdp_per_capita > 35 } } # set_temp_variable = { gdp_scaler = gdp_per_capita } # subtract_from_temp_variable = { gdp_scaler = 35 } # multiply_temp_variable = { gdp_scaler = -2 } # add_to_temp_variable = { AI_country_score = gdp_scaler } # AI Support the other AI if = { limit = { OR = { num_of_available_civilian_factories < 15 check_variable = { treasury_rate < 1.00 } } } add_to_temp_variable = { AI_country_score = 30 } } # Invest in Enemy of my Enemy if = { limit = { OR = { any_enemy_country = { has_war_with = ROOT } any_enemy_country = { has_opinion = { target = ROOT value < -50 } } } } add_to_temp_variable = { AI_country_score = 30 } } set_temp_variable_to_random = { var = randomizer_country_score min = 25 max = 75 integer = yes } subtract_from_temp_variable = { AI_country_score = randomizer_country_score } set_temp_variable = { investments_score_modifier = 1 } subtract_from_temp_variable = { investments_score_modifier = THIS.modifier@receiving_investment_cost_modifier } add_to_temp_variable = { investments_score_modifier = inv_cost_modifier } clamp_temp_variable = { var = investments_score_modifier min = 0.50 max = 1.50 } multiply_temp_variable = { AI_country_score = investments_score_modifier } set_temp_variable = { investments_duration_modifier = 1 } add_to_temp_variable = { investments_duration_modifier = THIS.modifier@receiving_investment_duration_modifier } add_to_temp_variable = { investments_duration_modifier = inv_duration_modifier } clamp_temp_variable = { var = investments_duration_modifier min = 0.50 max = 1.50 } multiply_temp_variable = { AI_country_score = investments_duration_modifier } }