AI Building Selection

Lplate

Esus (Allegedly)
Joined
Feb 8, 2011
Messages
578
Location
Ireland
Hi,

Could someone tell me which parameters and formulas are used by the AI when deciding which building or wonder to build?

Thanks
 
This is mostly decided in the CvCityAI::AI_buildingValueThreshold SDK method which is over 1200 lines of code long, so it's not something that can be easily summed up in a few sentences.

It depends on many factors such as the happiness / health of the city, what type of victory the AI is aiming towards, what the city itself is focussing on, whether you are at war, whether the building will improve your commerce or not, what religion you are running, whether you have the holy city for a religion, what your civics are, the list goes on...
 
This is mostly decided in the CvCityAI::AI_buildingValueThreshold SDK method which is over 1200 lines of code long, so it's not something that can be easily summed up in a few sentences.

Most of that would probably be irrelevant for my purposes.
I'm working on a modular civilization which uses a lot of unique wonder buildings. In my current version the AI is correctly building these. When I adjusted the iCost and iAsset values, the AI seemed to stop building them.

My main interest would be in how the AI uses the iCost, iAsset and iPower values when determining what to build.
E.g if I increase an iCost or iAsset value by 20 percent, what impact would this have on the likelihood of the AI choosing to build the wonder?

I'll run a few more experiments with xml editing but a little visibility on how those particular parameters are used (if they are used) when the AI is making its choice would be great.
 
Of the three it is only iCost that will impact the AI choice of production. It defines the number of hammers needed to finish the building and the cheaper it is relative to other buildings the more likely the AI is to construct it. The AI is pretty dumb as it is and reducing the cost of a building to try and force the AI to construct it can handicap it even further. Obviously it is your mod so your choice, but be careful you don't skew the game balance too much making wholesale changes to the cost of buildings.

The Civ Fanatics Modding Wiki has a description of what most of the elements in the XML files do. It is a good modding reference with some handy tutorials (along with those on this forum)
 
Thanks for the info. It explains why the AI stopped building my wonders when I increased the cost.
 
I need to increase the iCost of the civilization's wonders as it's too easy for a human player to maximise/exploit the benefit from these wonders at the current prices.

Could the AI be encouraged to build these more expensive wonders by creating a civ specific Flavor and specifying this for the civ leader and the civ wonder buildings?
 
I'm not sure if this is what you are after, but in the .xml files there is AIweight which encourages/discourages the AI from building projects or buildings. E.g. I want to encourage Elegy of the Sheiam so I increased the iAIweight. Civ4buildinginfos.xml seems to have the same thing.
 
I'm not sure if this is what you are after, but in the .xml files there is AIweight which encourages/discourages the AI from building projects or buildings. E.g. I want to encourage Elegy of the Sheiam so I increased the iAIweight. Civ4buildinginfos.xml seems to have the same thing.

That sounds like exactly what I need to look at.
 
On a related note, it seems that different civs prioritise certain units (unless it's just the terrain I put them in but they have pretty similar terrain) - the Kuriotates build a worker straight away whereas most others go for warriors. Does anyone know what controls this please?
 
<UnitAIWeightModifier> in CIV4LeaderHeadInfos?
 
On a related note, it seems that different civs prioritise certain units (unless it's just the terrain I put them in but they have pretty similar terrain) - the Kuriotates build a worker straight away whereas most others go for warriors. Does anyone know what controls this please?

This most likely has nothing to do with the civilization. My guess is that the civs that build warriors first settle away from their starting point, leaving their starting troops to follow. They then run some checks to see what to produce, see that their city is defenseless and choose to build a warrior. This is pretty common in FFH due to the Starting Settler promotion which gives the initial settler extra moves and sight.
 
Back
Top Bottom