City valuation - Infixo/Civ6-Real-Strategy GitHub Wiki
Formula
city_value = residual_value + base_vale + capital_value + population_value - defending_units_value - defenses_value
- residual_value: This value is calculated by the engine and is not logged anywhere; the formula is unknown; it is the value of the city itself, its land, improvements, districts, etc. It is correlated with the city development. The easiest way to find out this value is to run the valuation with all PseudoYields set to 0 (ex. CITY_DEFENSES- it must be 1, 0 crashes the game). The actual residual_value is off slightly (due to defenses counted with 1, but it is negligible). The residual values is different for various AIs, so it must be based on yields' and pseudoyields' values that a given AI is using at the moment.
Observation: rule of thumb is residual_value ~= population * 100-150. Big cities (20+ pop) have value of 2000+ late game.
- base_value: Value of PSEUDOYIELD_CITY_BASE. This can be negative, 0 or positive.
- capital_value: If the city is the original capital, then the value of PSEUDOYIELD_CITY_ORIGINAL_CAPITAL is added. This also applies to minors. Each minor is a capital.
- population_value= math.floor(population/5) * PSEUDOYIELD_CITY_POPULATION, i.e. every 5 citizens is worth PSEUDOYIELD_CITY_POPULATION.
- defending_units_value: The game calculates the strength of units around a city (sum_strength). All units up to 3 tiles away are considered, including a garrison. Attack strength is summed i.e. for ranged units it is ranged strength, not combat strength. Then
defending_units = PSEUDOYIELD_CITY_DEFENDING_UNITS * (1 + sum_strength/28)
. - defenses_value=
(city_strength + 37) * PSEUDOYIELD_CITY_DEFENSES / 28
. The game subtracts the value correlated to the strength of the city itself. This applies only when city_strength > 25, if city_strength is less than that, a standard factor is applied which is not affected by pseudo value at all.
Yet to be tested: how walls affect it e.g. is it just more strength (each level adds +2) or some other formula, how encampments affect it e.g. are they considered at all
AiFavoredItems
The PseudoYield value is modified by AiFavoredItems before applying. Standard formula:
pseudo_value = pseudo_default * (1 + math.max(sum_of_active_favored_items, -100)/100)
Default values
Vanilla game
- PseudoYieldType="PSEUDOYIELD_CITY_BASE" DefaultValue="450"
- PseudoYieldType="PSEUDOYIELD_CITY_DEFENSES" DefaultValue="200"
- PseudoYieldType="PSEUDOYIELD_CITY_DEFENDING_UNITS" DefaultValue="80"
- PseudoYieldType="PSEUDOYIELD_CITY_ORIGINAL_CAPITAL" DefaultValue="200"
- PseudoYieldType="PSEUDOYIELD_CITY_POPULATION" DefaultValue="50"
Real Strategy up to v2.2
CITY_BASE 450
CITY_DEFENSES 275
CITY_DEFENDING_UNITS 50
CITY_ORIGINAL_CAPITAL 200
CITY_POPULATION 75
Real Strategy v2.3 and further
CITY_BASE 750
CITY_DEFENSES 40
CITY_DEFENDING_UNITS 100
CITY_ORIGINAL_CAPITAL -200
CITY_POPULATION 0
(not used)
Log
AI_Operation_Eval.csv, Operation Name = "CITY VALUES"
Comment about PSEUDOYIELD_CITY_* from AI+
These values appear to determine not just how to value cities to attack, but also how likely it is we attack any. Based on testing:
- PSEUDOYIELD_CITY_BASE if positive makes it more likely we'll attack
- PSEUDOYIELD_CITY_DEFENSES if positive makes it LESS likely we'll attack (times city defence? maybe walls?)
- PSEUDOYIELD_CITY_DEFENDING_UNITS if positive makes it LESS likely we'll attack (times unit count?)
- PSEUDOYIELD_CITY_ORIGINAL_CAPITAL if positive, increases desire to attack capitals
- PSEUDOYIELD_CITY_POPULATION if positive, probably increases desire (too lazy to check)