• Our friends from AlphaCentauri2.info are in need of technical assistance. If you have experience with the LAMP stack and some hours to spare, please help them out and post here.

[BTS] AI Civics

scheines

Warlord
Joined
Feb 4, 2020
Messages
129
I saw a BUG tip yesterday that said to watch civics, since it could give clues regarding your opponent’s goals (e.g. theocracy -> making units). Surely this works vs human opponents; does it work on the AI?

Moreover, what drives AIs civics, aside from one being their favorite? For instance, I can’t remember the last time I saw an AI in pacifism or nationhood.
 
In CvPlayerAI, AI_doTurnPre() (called at the start of each turn) calls AI_doCivics. AI_doCivics makes sure the AI is allowed to change civics, and hasn't swapped too recently, then assuming that's true tries to shift into the civics that evaluate highest on AI_bestCivic(). AI_bestCivic() gets a score for each civic based on AI_civicValue(), then increases the value of current civics by x1.2 if it would take non-zero turns to switch civics, or x16/15 if switches are free (to make AI civic choices a little "sticky").

But the bulk of the work is done by AI_civicValue, which is about a 300-line function adding up values for various things that civics might give. Avoiding emancipation anger is worth points. Additional GPP rate is worth points. Reduced military upkeep is worth points. Reduced corporate maintenance is worth points. And so forth, and so on. Big long list. "Favorite civic" adds a pretty hefty boost on to the score at the end of the evaluation, which is why AIs tend to be in their favorite civics - although if the game situation was really favorable for something else, from their perspective, they could switch.
 
Back
Top Bottom