Hi y’all, the old thread got archived, so I’m making a new one for the update. The (mod)mod could also use a bit more visibility, as I still think it has a decent chance at being integrated into base VP. Some people on Discord recently shown interest and had good experiences, it's still anecdotal for now, we need more players & reports. So give it a try, leave a comment, and maybe you’ll start seeing more flavorfully balanced AI armies soon. Get it here: Unit Production AI Improvements
In short, this modmod introduces soft checks to AI army composition to help it create more balanced armies. This is done by introducing new AIMilitaryStrategies, Flavors and UNITAIs for each unit type*. When an AI player has too few of a certain unit type, it gets a bonus to prioritize the production of that type, and vice versa when it has too much. For a long description on what it does and why, please refer to: https://github.com/LoneGazebo/Community-Patch-DLL/pull/8783
NeedArcher: NumArcher / NumMelee <= 1/4 * AIFlavor / 5, EnoughArcher: NumArcher / NumMelee >= 1/2 * AIFlavor / 5
NeedMobile: NumMobile / NumMelee <= 1/4 * AIFlavor / 5, EnoughMobile: NumMobile / NumMelee >= 1/2 * AIFlavor / 5
NeedSiege: NumSiege / NumMelee <= 1/8 * AIFlavor / 5, EnoughSiege: NumSiege / NumMelee >= 1/2 * AIFlavor / 5
NeedSkirmisher: NumSkirmisher / NumMelee <= 1/8 * AIFlavor / 5, EnoughSkirmisher: NumSkirmisher / NumMelee >= 1/2 * AIFlavor / 5
NeedNavalMelee: NumNavalMelee / NumNavy <= 3/10 * AIFlavor / 5, EnoughNavalMelee: NumNavalMelee / NumNavy >= 7/10 * AIFlavor / 5
NeedNavalRanged: NumNavalRanged / NumNavy <= 3/10 * AIFlavor / 5, EnoughNavalRanged: NumNavalRanged / NumNavy >= 7/10 * AIFlavor / 5
NeedSubmarine: NumSubmarine / NumNavy <= 1/10 * AIFlavor / 5, EnoughSubmarine: NumSubmarine / NumNavy >= 3/10 * AIFlavor / 5
NeedBomber: NumBomber / NumAir <= 3/10 * AIFlavor / 5, EnoughBomber: NumBomber / NumAir >= 7/10 * AIFlavor / 5
NeedFighter: NumFighter / NumAir <= 3/10 * AIFlavor / 5, EnoughFighter: NumFighter / NumAir >= 7/10 * AIFlavor / 5
I welcome any feedback on the ratios above or suggestions where we can further employ these additions. Just to give an example, I modified AIGrandStrategy_FlavorMods so that civs going for domination get a bonus to bombers and siege units, while the culture, diplomacy and science get it for fighters.
If the results are good this may get integrated into the base VP, so any testing is much appreciated.
You can check the AI army composition through Logs/MilitarySummary.csv
Turn, Player, Era, Cities, Settlers, LandUnits, LandArmySize, RecLandOffensive, RecLandDefensive, NavalUnits, NavalArmySize, RecNavyOffensive, MeleeUnits, MobileUnits, ReconUnits, ArcherUnits, SiegeUnits, SkirmisherUnits, AllLandRanged, AntiAirUnits, MeleeNavalUnits, RangedNavalUnits, Submarines, Carriers, TotalAirUnits, BomberUnits, FighterUnits, Nukes, Missiles, RecTotal, TotalMilitaryUnits, SupplyLimit, OutOfSupply, WarWearinessSupplyReduction, NoSupplyUnits, WarCount, MostEndangeredCity, Danger
Works with new units/civs/leaders. I specifically tested with 4UC, ENW, Macedon/Greece Split and Kushan Empire, highly unlikely that other custom civs will have any issues. Units will get assigned the correct UNITAI but may miss specific flavors and the new leaders will get the default flavor value of 5 for new flavors. To be honest this shouldn't matter much, UUs get spammed by another function anyway. You can make your custom leader optimized for UPAI by referencing new flavors/unitais with a IF EXISTS check.
Many thanks to Recursive, ilteroi and the discord community for their help.
Requires VP 2.1 or later.
To-Do:
- Rewrite need/have enough recon code (UPAI doesn't modify this as it's handled by another part of the code)
- Better integration between new flavors and technologies&policies
- A trigger to auto-detect UUs and give boost to related flavor of custom leaders
*unit type in this context refers to the broader types such as melee, ranged, bomber, fighter, not the specific unit types used in database like "unit_mongolian_keshik"
Moderator Action: Moving this to the main forum for visibility because AI improvements good. - Recursive
23/04 - v2 : Very small update, doesn't warrant a bump. You can find options to reduce Leader Flavor randomization in NewLeaderFlavors.sql . The same file also includes and option to remove randomization from city production decisions (includes both buildings and units). Both are commented out/disabled by default to make comparisons with the base VP more reliable. No need to download v2 if you won't enable them.
09/05/2025 - v3: Fixed triggers, modmod should properly consider custom units now. Thanks @hokath for reporting!
In short, this modmod introduces soft checks to AI army composition to help it create more balanced armies. This is done by introducing new AIMilitaryStrategies, Flavors and UNITAIs for each unit type*. When an AI player has too few of a certain unit type, it gets a bonus to prioritize the production of that type, and vice versa when it has too much. For a long description on what it does and why, please refer to: https://github.com/LoneGazebo/Community-Patch-DLL/pull/8783
Spoiler Current formula :
NeedArcher: NumArcher / NumMelee <= 1/4 * AIFlavor / 5, EnoughArcher: NumArcher / NumMelee >= 1/2 * AIFlavor / 5
NeedMobile: NumMobile / NumMelee <= 1/4 * AIFlavor / 5, EnoughMobile: NumMobile / NumMelee >= 1/2 * AIFlavor / 5
NeedSiege: NumSiege / NumMelee <= 1/8 * AIFlavor / 5, EnoughSiege: NumSiege / NumMelee >= 1/2 * AIFlavor / 5
NeedSkirmisher: NumSkirmisher / NumMelee <= 1/8 * AIFlavor / 5, EnoughSkirmisher: NumSkirmisher / NumMelee >= 1/2 * AIFlavor / 5
NeedNavalMelee: NumNavalMelee / NumNavy <= 3/10 * AIFlavor / 5, EnoughNavalMelee: NumNavalMelee / NumNavy >= 7/10 * AIFlavor / 5
NeedNavalRanged: NumNavalRanged / NumNavy <= 3/10 * AIFlavor / 5, EnoughNavalRanged: NumNavalRanged / NumNavy >= 7/10 * AIFlavor / 5
NeedSubmarine: NumSubmarine / NumNavy <= 1/10 * AIFlavor / 5, EnoughSubmarine: NumSubmarine / NumNavy >= 3/10 * AIFlavor / 5
NeedBomber: NumBomber / NumAir <= 3/10 * AIFlavor / 5, EnoughBomber: NumBomber / NumAir >= 7/10 * AIFlavor / 5
NeedFighter: NumFighter / NumAir <= 3/10 * AIFlavor / 5, EnoughFighter: NumFighter / NumAir >= 7/10 * AIFlavor / 5
I welcome any feedback on the ratios above or suggestions where we can further employ these additions. Just to give an example, I modified AIGrandStrategy_FlavorMods so that civs going for domination get a bonus to bombers and siege units, while the culture, diplomacy and science get it for fighters.
If the results are good this may get integrated into the base VP, so any testing is much appreciated.
You can check the AI army composition through Logs/MilitarySummary.csv
Spoiler The header gets removed from the log file after reload, you can copy/paste the line below and open with Excel etc. to get a readable view :
Turn, Player, Era, Cities, Settlers, LandUnits, LandArmySize, RecLandOffensive, RecLandDefensive, NavalUnits, NavalArmySize, RecNavyOffensive, MeleeUnits, MobileUnits, ReconUnits, ArcherUnits, SiegeUnits, SkirmisherUnits, AllLandRanged, AntiAirUnits, MeleeNavalUnits, RangedNavalUnits, Submarines, Carriers, TotalAirUnits, BomberUnits, FighterUnits, Nukes, Missiles, RecTotal, TotalMilitaryUnits, SupplyLimit, OutOfSupply, WarWearinessSupplyReduction, NoSupplyUnits, WarCount, MostEndangeredCity, Danger
Works with new units/civs/leaders. I specifically tested with 4UC, ENW, Macedon/Greece Split and Kushan Empire, highly unlikely that other custom civs will have any issues. Units will get assigned the correct UNITAI but may miss specific flavors and the new leaders will get the default flavor value of 5 for new flavors. To be honest this shouldn't matter much, UUs get spammed by another function anyway. You can make your custom leader optimized for UPAI by referencing new flavors/unitais with a IF EXISTS check.
Many thanks to Recursive, ilteroi and the discord community for their help.
Requires VP 2.1 or later.
To-Do:
- Rewrite need/have enough recon code (UPAI doesn't modify this as it's handled by another part of the code)
- Better integration between new flavors and technologies&policies
- A trigger to auto-detect UUs and give boost to related flavor of custom leaders
*unit type in this context refers to the broader types such as melee, ranged, bomber, fighter, not the specific unit types used in database like "unit_mongolian_keshik"
Moderator Action: Moving this to the main forum for visibility because AI improvements good. - Recursive
23/04 - v2 : Very small update, doesn't warrant a bump. You can find options to reduce Leader Flavor randomization in NewLeaderFlavors.sql . The same file also includes and option to remove randomization from city production decisions (includes both buildings and units). Both are commented out/disabled by default to make comparisons with the base VP more reliable. No need to download v2 if you won't enable them.
09/05/2025 - v3: Fixed triggers, modmod should properly consider custom units now. Thanks @hokath for reporting!
Last edited: