Split procurement settings for blue & red

Resolves #208
This commit is contained in:
Raffson 2023-10-07 13:53:29 +02:00
parent 1ebc289fb7
commit cb6bffe3ec
No known key found for this signature in database
GPG Key ID: B0402B2C9B764D99
2 changed files with 57 additions and 6 deletions

View File

@ -76,7 +76,12 @@ class ProcurementAi:
cp_aircraft = cp.allocated_aircraft(parking_type)
aircraft_investment += cp_aircraft.total_value
air = self.game.settings.auto_procurement_balance / 100.0
balance = (
self.game.settings.auto_procurement_balance
if self.is_player
else self.game.settings.auto_procurement_balance_red
)
air = balance / 100.0
ground = 1 - air
weighted_investment = aircraft_investment * air + armor_investment * ground
if weighted_investment == 0:
@ -269,7 +274,12 @@ class ProcurementAi:
# No source of ground units, so can't buy anything.
continue
fr_factor = self.game.settings.frontline_reserves_factor / 100.0
reserves_factor = (
self.game.settings.frontline_reserves_factor
if self.is_player
else self.game.settings.frontline_reserves_factor_red
)
fr_factor = reserves_factor / 100.0
purchase_target = cp.frontline_unit_count_limit * fr_factor
allocated = cp.allocated_ground_units(
self.game.coalition_for(self.is_player).transfers
@ -303,7 +313,12 @@ class ProcurementAi:
allocated = cp.allocated_ground_units(
self.game.coalition_for(self.is_player).transfers
)
if allocated.total >= self.game.settings.reserves_procurement_target:
target = (
self.game.settings.reserves_procurement_target
if self.is_player
else self.game.settings.reserves_procurement_target_red
)
if allocated.total >= target:
continue
if allocated.total < worst_supply:

View File

@ -477,7 +477,7 @@ class Settings:
default=True,
)
auto_procurement_balance: int = bounded_int_option(
"AI ground unit procurement budget ratio (%)",
"AI ground unit procurement budget ratio (%) for BLUE",
CAMPAIGN_MANAGEMENT_PAGE,
HQ_AUTOMATION_SECTION,
min=0,
@ -490,7 +490,7 @@ class Settings:
),
)
frontline_reserves_factor: int = bounded_int_option(
"AI ground unit front-line reserves factor (%)",
"AI ground unit front-line reserves factor (%) for BLUE",
CAMPAIGN_MANAGEMENT_PAGE,
HQ_AUTOMATION_SECTION,
min=0,
@ -502,7 +502,43 @@ class Settings:
),
)
reserves_procurement_target: int = bounded_int_option(
"AI ground unit reserves procurement target",
"AI ground unit reserves procurement target for BLUE",
CAMPAIGN_MANAGEMENT_PAGE,
HQ_AUTOMATION_SECTION,
min=0,
max=1000,
default=10,
detail=(
"The number of units that will be bought as reserves for applicable control points"
),
)
auto_procurement_balance_red: int = bounded_int_option(
"AI ground unit procurement budget ratio (%) for RED",
CAMPAIGN_MANAGEMENT_PAGE,
HQ_AUTOMATION_SECTION,
min=0,
max=100,
default=50,
detail=(
"Ratio (larger number -> more budget for ground units) "
"that indicates how the AI procurement planner should "
"spend its budget."
),
)
frontline_reserves_factor_red: int = bounded_int_option(
"AI ground unit front-line reserves factor (%) for RED",
CAMPAIGN_MANAGEMENT_PAGE,
HQ_AUTOMATION_SECTION,
min=0,
max=1000,
default=130,
detail=(
"Factor to be multiplied with the control point's unit count limit "
"to calculate the procurement target for reserve troops at front-lines."
),
)
reserves_procurement_target_red: int = bounded_int_option(
"AI ground unit reserves procurement target for RED",
CAMPAIGN_MANAGEMENT_PAGE,
HQ_AUTOMATION_SECTION,
min=0,