CvEconomicAI Strategies

ReasoningMass

Chieftain
Joined
Nov 14, 2013
Messages
15
Location
Minnesota
Anyone understand how the Economic Strategies work in CvEconomicAI.cpp?

I get the "IsTestStrategy" functions are called every turn in CvEconomicAI:: DoTurn() to test if each strategy should be used. After that though? There doesn't seem to be any code that states what the strategies actually do.

Of course checking the CIV5AIEconomicStrategies.xml just raises more questions. I think I understand the flavor modifiers (DoTurn() checks each used strategies flavor modifier and adds it to the players base flavors) but where exactly does the code handle things like <FirstTurnExecuted> or <CheckTriggerTurnCount>?
 
Think of the AI as having a number of piles of "flavour" - labelled things like "offense", "defense", "recon", "expand", etc

The personality of the leader and their chosen grand strategy dumps stuff into those piles. The currently active economic and military strategies dump more stuff into some of those piles. When the AI needs to decide what to do next, the size of the piles influence the decision - eg what unit/building to build in a city.

The code in CvEconomicAI.cpp is just a part of the overall mechanism, you'll also need to look for where the AI uses the values in the piles of stuff.

A good search tool will turn up where FirstTurnExecuted and CheckTriggerTurnCount are read from the XML by the C++ code, which you can then use to find where the accessors are used within the main code
 
Thanks for the help :)

I guess my confusion came from FoundCity and a couple others which don't add any flavors. It looks like those are just used to start their respective operations from their IsTestStrategy functions.
 
Top Bottom