Siesta Guru
Prince
From what I've been reading since the game was released, the primary root causes of AI incompetency in combat are:
- AI currently overvalues unit self-preservation. e.g. even if they have a strong unit, they are reluctant to bring it near a walled city because god forbid their HP goes down from 100 to 96. If they do decide to bring it, as soon as it takes a hit, it wants to retreat and heal.
- AI units don't behave as a "pack", it's more each-for-his-own kind of mentality. So they don't "sacrifice" or "risk" any units because every life is precious
- AI is indecisive. e.g. one turn a unit gets orders to attack a city, next turn the orders might change to "chill out"
@Siesta Guru explains all this a lot more eloquently in the AI+ mod threads. https://forums.civfanatics.com/resources/ai.25439/
I understand some of this he is able to tweak but most of the behavior is in the SDK that only the devs have access to today
This is indeed mostly what's going on.
The self-preservation point is slightly off though. It doesn't do any individual unit self-preservation tactics like running away as long as it's above a certain threshold. If you see these units run away at high health, it's most likely that on an operational, team level, it decides that the situation is unwinnable. It could also actually not be running away, but could for example be wandering or trying to pillage. They do however sometimes choose not to attack units even if at full health if the combat strength of the target is significantly above their own. This is especially obvious around cities in later eras, as their combat strengths tend to be way above that of units.
The indecisiveness seems to partially be because individual units don't appear to be any memory. If there's several possible things they could be doing, and it can't decide on one of these being significantly better than the others. Then small changes in environmental factors will make them switch targets/types of behavior on every turn, often causing them to bounce back and forth.
I'd also add that the units appear to have no, or very little concept of terrain and distances. It doesn't seem to think about say trying to end a turn on a hill next to a river. And it's 'running away' movement just runs it away from what seems to be a nearby unit, without care for whether its new position will be reachable by enemy units.
In vanilla (fixed this in AI+), there's also some nasty issues where the AI fails to reach a condition and then gets stuck. The worst was requiring all units in its operation to be within 2 tiles of an enemy city/a gathering point. Which was often impossible due to too many units for the amount of tiles available to move to. Which was most commonly seen as units getting stuck on borders/just kind of standing around in your terrain and sometimes as them just staring cities down for hundreds of years.
The AI is especially in later eras also significantly held back by the game design and balance. The high city combat/health and healing in renaissance and up, require endured competent play to even stand a chance of taking a city. The AI is nowhere near the level required for that.
Also, In later eras the production costs of units ramp up so much, that it even takes the deity AI (whose economic bonuses are more like immortal in civ 5) 6-10 turns to build a single unit. On top of that, to make them actually competitive in culture/faith while production is necessary, they're forced to underbuild commercial districts, leaving them without money to sustain and upgrade their troops, disbanding is common even on deity. And even if they have the money to upgrade, they might not have the necessary resources. Leading to small underdeveloped armies after classical.
They're also really bad at using the correct policies to counter these issues, they'll get a military policy to build city walls faster over something to increase military unit production, even if it's building units over walls. And they will get the policy to reduce the cost to purchase tiles in a wildcard slot over the reduced maintenance cost, despite them sitting at 0 gold and -8 gpt.
Not that it even matters that much in later eras, since there appears to be a bug (?) that makes city assault operations be significantly less likely to even be considered.