AI Question

hj232

Chieftain
Joined
Mar 9, 2006
Messages
28
When I change things in XML concerning unit strengths and abilities, etc. How do I make sure that the AI now knows how to properly use the changed units? Also, what command line places a level of importance on what the AI builds? How does it know to build the Pyramids as opposed to the Great Wall? And why does the AI change civics?

Thanks
 
hj232 said:
When I change things in XML concerning unit strengths and abilities, etc. How do I make sure that the AI now knows how to properly use the changed units? Also, what command line places a level of importance on what the AI builds? How does it know to build the Pyramids as opposed to the Great Wall? And why does the AI change civics?

Thanks

The ai uses different values depending on it's leaderhead's various parameters to determine how one unit is better than another.

Each unit has a different UnitAI type. Typically, the AI will look to see what kind it wants (if it's an agressive AI, it will probably build more attacking units, where as a less aggressive will build more city defending units). For every unit, the different variables are checked to see what would be best. For example, if you change a unit strength on a unit, the unit's rating to the AI will raise some. Lower it, and the AI will lower how it feels about making that unit.

It all comes down to this: every unit is given their shot to be built. The AI assigns some single numeric value to it, taking into consideration a ton of different things. The unit with the highest numeric value will be chosen.

When it comes to making SURE that the AI knows how to use it, there's really not much to do. Changing just XML values should be enough to know that the AI will know if you've made a change for the better or worse. The problem comes if you're making a completely NEW xml trait (by modifying the SDK) or using python to give that unit special abilities (like the ability to cast spells by either modifying the SDK or python). However, each xml trait is calculated alongside the others for the AI, and if just editing that, then the AI will use it's same decision-making process.

This is the same for most things, although some objects (such as buildings) have a tag (normally called "iAIWeight") which allows you to make this building more or less important for the AI to create.

The AI normally changes civics based upon various factors, all of which can be found by scrounging through the many lines of code in the SDK. Check out the CvPlayerAI.cpp, and look for functions (those blocks of lines that start with CvPlayerAI::AI_(something here) ) for those dealing with civics. Even if you don't know c++, you can probably semi-make out what they're doing. Typically, there's a function that gets the value of a certain civic, which, when the AI is trying to decide which to pick, they look for the one with the highest value.
 
Back
Top Bottom