Add slider option for weighted AI procurement

Resolves #81
This commit is contained in:
Raffson 2023-02-05 23:29:01 +01:00
parent 22835e7535
commit 3fc82af3ac
No known key found for this signature in database
GPG Key ID: B0402B2C9B764D99
2 changed files with 19 additions and 4 deletions

View File

@ -73,13 +73,15 @@ class ProcurementAi:
cp_aircraft = cp.allocated_aircraft()
aircraft_investment += cp_aircraft.total_value
total_investment = aircraft_investment + armor_investment
if total_investment == 0:
air = self.game.settings.auto_procurement_balance / 100.0
ground = 1 - air
weighted_investment = aircraft_investment * air + armor_investment * ground
if weighted_investment == 0:
# Turn 0 or all units were destroyed. Either way, split 30/70.
return 0.3
return min(0.3, ground)
# the more planes we have, the more ground units we want and vice versa
ground_unit_share = aircraft_investment / total_investment
ground_unit_share = aircraft_investment * air / weighted_investment
if ground_unit_share > 1.0:
raise ValueError

View File

@ -273,6 +273,19 @@ class Settings:
HQ_AUTOMATION_SECTION,
default=True,
)
auto_procurement_balance: int = bounded_int_option(
"AI ground unit procurement budget ratio (%)",
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."
),
)
reserves_procurement_target: int = 10
# Mission Generator