Questions about running a deficit and unit gold support

Pazyryk

Deity
Joined
Jun 13, 2008
Messages
3,584
For modding purposes, I need a better understanding of what happens when a civ runs a gold deficit, both game-enforced stuff (for human player) and AI behavior. I assume that DEFICIT_UNIT_DISBANDING_THRESHOLD (=5) determines the deficit level where units start getting disbanded by the game engine. But,
  • will "free" military or civilian units ever be deleted (either by game engine or AI "choice")?
  • does the AI start doing stuff (disbanding, selling buildings) before this?
  • does the game engine ever do more, like forced building-sales?

Also, does anyone know (or have a link to) the equation that determines military and non-military unit costs? I can see that there are 5 (possibly) relevant tags in GlobalDefines:

INITIAL_GOLD_PER_UNIT_TIMES_100 = 50
INITIAL_FREE_OUTSIDE_UNITS = 3
INITIAL_OUTSIDE_UNIT_GOLD_PERCENT = 0 --what's this?
UNIT_MAINTENANCE_GAME_MULTIPLIER = 8
UNIT_MAINTENANCE_GAME_EXPONENT_DIVISOR = 7

...and more in Policies:

BaseFreeUnits, BaseFreeMilitaryUnits, FreeUnitsPopulationPercent, FreeMilitaryUnitsPopulationPercent,GarrisonFreeMaintenance, GoldPerUnit, GoldPerMilitaryUnit, UnitGoldMaintenanceMod, UnitSupplyMod

...but the actual equation would be really helpful. I also don't really understand how BaseFreeUnits is applied versus BaseFreeMilitaryUnits (maybe I'm remembering from Civ4, but for some reason I don't think it works in a very intuitive way).
 
...but the actual equation would be really helpful.

Ask and ye shall receive! Alpaca figured it out on page 5 of that thread, a bit more than a year ago:

Code:
c(t,n) = ((j/100 + m/1000 t) round(n,2))^(1 + 2/(1000*d) t)

where j = INITIAL_GOLD_PER_UNIT_TIMES_100, m = UNIT_MAINTENANCE_GAME_MULTIPLIER, d = UNIT_MAINTENANCE_GAME_EXPONENT_DIVISOR, n = number of units, t = number of turns

I think the two 1000 values might be tied to the maximum number of turns (500 in a default normal-speed game), to where games on Marathon or Epic use 1500 or 3000 instead, and mods that change the maximum number of turns (like mine) change it as well.

Also, the round(n,2) was replaced with a straight n in a later patch to get rid of the even-number issues people were having. And that n is actually (n-3), where the 3 are the free units (which can be increased through policies and such).
 
Back
Top Bottom