How does the AI choose ideology?

Halpo

Chieftain
Joined
Feb 5, 2016
Messages
5
Recently, I've been furiously testing a mod that overhauls the ideologies, and the AI is extremely biased toward Freedom (which I've renamed "Prosperity"). I start in the modern era, put all of my units to sleep, and wait to see what's chosen; at least 5 out of 7 pick Prosperity, sometimes 6 out of 7. The minority ideology/ies are always Equality (Order), never Unity (Autocracy).

This doesn't happen when starting from the modern era without mods.

I'm under the impression that the AI weighs the following when choosing ideology:
* tourism of civs that have already chosen ideologies -- irrelevant for my tests because no one had any tourism and because no one had met anyone else
* number of free policies -- also irrelevant because no free policies were offered
* flavors of the policies offered by the ideology
* available victory conditions

Regarding the last item, I've discovered that disabling diplomatic victory causes the AI to always pick Order, *without* mods. Even if you change the flavors, this seems to be true -- presumably because the AI is hardcoded to take into account the three recommended victory types for each ideology.

Anyway, I've spent hours playing with flavors and looking for typos, and nothing has changed. Finally, I deleted a hundred forty points of flavor from policies of Prosperity -- still nothing changed.

I'm certain that I never accidentally disabled conquest victory or any other victory type when testing.

I'm all out of ideas. Does anyone know something about this that I don't?
 
Condensed AI algorithm from the C++ code
Code:
	// First consideration is our victory type
	int iConquestPriority = max(0, pPlayer->GetGrandStrategyAI()->GetConquestPriority());
	int iDiploPriority = max(0, pPlayer->GetGrandStrategyAI()->GetUnitedNationsPriority());
	int iTechPriority = max(0, pPlayer->GetGrandStrategyAI()->GetSpaceshipPriority());
	int iCulturePriority = max(0, pPlayer->GetGrandStrategyAI()->GetCulturePriority());
	
	int iFreedomTotal = iDiploPriority + iTechPriority + iCulturePriority;
	int iAutocracyTotal = iDiploPriority + iConquestPriority + iCulturePriority;
	int iOrderTotal = iTechPriority + iConquestPriority + iCulturePriority;

	// Rule out one ideology if we are clearly (at least 25% more priority) going for the victory this ideology doesn't support

	// Next look at free policies we can get

	// Finally see what our friends (and enemies) have already chosen

	// Look at Happiness impacts
	// -- Happiness we could add through tenets
	// -- Happiness we'd lose through Public Opinion

	// Small random add-on

	// Rule out any branches that are totally out of consideration

	// Pick the ideology
 
Thanks.

// -- Happiness we could add through tenets
How does the code evaluate happiness? Does it just look at the flavors, or does it calculate actual benefits? If the latter is the case, it wouldn't be able to recognize happiness via dummy buildings or other Lua-related effects, right?

// Rule out any branches that are totally out of consideration
What does this mean?
 
Tenets that directly grant buildings that add happiness, eg Prora

"totally out of consideration" - seems to be an artefact, as all it does it ditch the ideology marked as "out" from the AI's chosen VC

Full details can be found in CvPolicyAI:: DoChooseIdeology()
 
Top Bottom