Trying to understand the AI - what it can and cannot do??

kc_bandit

Chieftain
Joined
Feb 8, 2012
Messages
63
Here's my question: What can the AI do properly? Does it know not to attack a pike with a horse? Can it at least judge as to whether an attack is profitable? I am assuming it can do that because it seems to make correct decisions in isolated cases.

But in an all out war? Their mix of units is pretty terrible. Monty's early rush with 5 Jags wouldn't be able to take out any city, let alone a human controlled city. At least they are pillaging and wreaking havok to some extent now. But you still see the AI move a Great General out of the city to sit him in harm's way, or an archer. And many times they don't even attack with a ranged unit that just sits there for no reason - or they move an artillary to end it's turn next to my mech infantry.

I realize that CIV is much more complex and difficult to teach an AI how and where to move/attack/defend versus other games like chess, but there are so many decisions it makes that are just terrible - and many cases where if the AI could just see the big picture they would know that accepting a peace deal when they have victory in one or two turns is not acceptable.

I could go on and on about trading and other areas. It just seems to be so lopsided with the only way to balance it by giving the AI extra units, more gold, more food, etc. And even then, if you can't defend your cities properly, all of that gold an AI has built up, huge city populations and wonders galore are going to be taken by a decent human player via combat. Oh - and sitting on 20k of gold with a dwindling army and not buying any units?? Or retreating instead of standing their ground and bringing in reinforcements?

If I might ask, if it is not too in depth of an answer - how did you improve AI decisions in VEM? Specifically, HOW do you do that with the game code? I am not asking about the results of what you did - but how do you tell the AI what to do in various situations or game states?

Like, if the AI sees 4 horseman on its doorstep, does it know to buy or build pikes and where to place them for maximum effectiveness? Can it be taught that basic concept?

Or how about this? The AI is five turns away from its invasion force reaching my borders - and I haven't the vaguest idea they are on their way. Why declare war five turns early instead of waiting until the last second and before reaching my territory? Or even worse, parking 7 units on my doorstep for 4 turns allowing me all the time in the world to prepare and then declaring war?

City State situations are even worse. I steal a couple of CS's from an AI through gifts of gold and have ZERO worries that they will take them back the next turn despite having 50k of gold sitting in reserve. In fact, it is more likely that they get angry with me and declare war - thereby wiping out all of their influence in a flash. Surely there is code that could be written that tells an AI ---- If declaring war, evaluate CS relationships with player you are going to declare war on - ally with their CS's, then declare.
 
Thanks. Please don't feel like you have to do anything in depth. Just trying to figure out the basics about what can and cannot be done with the AI.
 
The AI does weigh combat odds in deciding which units to attack. However, efficiently arranging a large number of units on the battlefield is actually impossible. It's basically a traveling salesman problem, deciding what's the best way to get to an arrangement of units in the shortest amount of moves. Humans basically deal with that problem by guessing.

However, that's only army placement and movement. Other things like what to build are much easier for the AI to decide. This is determined by "flavor" values. For example, in the Armies component of the project is a file with the flavor values for all the military units. Here's one line:

<Update><Where FlavorType="FLAVOR_OFFENSE" UnitType="UNIT_ARCHER" /> <Set Flavor="4" /><!-- 1 --></Update>

This means that for attacking units the AI considers archers to have a value of 4 (1 in vanilla). Spearmen have an offense flavor of 3. So archers are more heavily favored for strategies involving attacking than spearmen. Many more things which control the AI are exposed to us in the data files, which Sneaks and I altered in the "what would Gandhi do" (wwgd) component of the mod, and also in the Diplomacy component. For example, in the game's "GlobalDiplomacyAIDefines" file is this variable:

PEACE_WILLINGNESS_OFFER_THRESHOLD_ARMISTICE = 0

Higher numbers set a higher bar for the AI to be willing to offer an armistice, an end of hostilities without either side giving concessions. In vanilla this value is set very high at 40, and in VEM I lowered it to 0. This makes the AI more likely to offer an even peace treaty. In vanilla they often start a war, then ten turns later offer 5000:c5gold: to end it, or make absurd demands like asking for half our cities.
 
Top Bottom