Civ 6 Combat AI: Some Thoughts

Joined
Dec 28, 2016
Messages
525
Civ 6's combat AI can be good at times, but indecisive at others. I know many of us here would prefer the AI to be better at combat, but how can that be done? I thought it might be nice to start a new discussion on this aspect of the AI.

Combat using the 1-UPT system seems to be more challenging for the AI than the previous stack-based combat, as it can't just toss a big portion of its units into 1 square and just move that stack towards its target. From what I understand from the modding DB in Civ 6, the AI plans attacks using "operations teams" that have minimum and maximum unit limits (divided by unit types), and have specific purposes (walled city capture, regular city capture, city defense, some others). In theory, these kinds of teams would be great. But this system may be making the AI indecisive.

Thinking through AI war goals, this is the basic algorithm I've come up with so far:
  1. Identify the key target (capital city, closest neighboring city, etc.)
  2. Form a large army to attack the target
  3. Gather them in one area
  4. Determine how to get to the city and which spots to take up
  5. Move towards the city and take up position
  6. Begin the attack
I've seen the AI form groups and begin to move them, only to hesitate. I think the AI is very protective of its units, to the point where if it thinks it might lose the battle it'll retreat rather than try to continue. This is good in some cases, but since the AI has yield bonuses (and I think production ones too?), maybe it could be programmed to be a little less protective.

I think removing walls (I saw someone suggest that), reducing city attack strength, or going back to vulnerable cities might be helpful. On that note, I once modded all units to have a large combat strength bonus vs cities, and a barb scout razed one of my cities :D That's probably taking it too far :) It was nice though to be forced to make units to defend my cities.

What are your experiences with the combat AI? Have you noticed it doing really well in the latest patch? Which of those steps do you think it's not doing well on, or is it focusing too hard on movement and leaving its units vulnerable to being picked off?
 
Last edited:
Pathfinding in general is a pita for AI, so coordinating multiple units on an attack on a city being a challenge.

The most obvious issues I've seen is that the AI often seems to 'forget' about units (I think when they fall outside aforementioned operations). I.e. settlers that have lost their intended spot just left frozen has been an example given.

For me though, it's the most obvious when attacking the AI's cities. It sometimes has units that could attack me just sit there - I've even seen it not use it's city attack. This is beyond the explicit bug where if the AI asks for a peace deal and you refuse, it doesn't do any more attacks that turn. Sometimes it defends with units, sometimes it doesn't.
 
It shuffles units around each turn seemingly at random while you mow them down like a turkey shoot, its beyond pathetic.

A human player should not be able to build a dozen units and go on an endless conquering spree, or defend with impunity, killing hundreds of units and keeping all/most of the dozen alive... If 1UPT can't be made to work for AI then Stacks of Doom in some form need to make a comeback as I'm just sick of broken combat AI at this point. I want to feel threatened... Games are over as soon as I've built a handful of units basically. Booooring!
 
Indeed, one of the major pitfalls of the AI seems to be it is too much objective-focused. Anything out of its immediate objective gets "frozen".

Just went out of a game were I started a war with Arabia to avoid them forward-settling me. I captured the settler, but I intended to give it back once I secured the land with a city of my own.

When I was ready, it seems AI had already started the "attack city X" routine (other of my border cities), as I got the settler just next to his units, but none of them captured it.

They pushed hard towards my city (and I was next to losing it, altough I could manage a good defense with two archers and a warrior). It was only after the AI ceded on this objective one of his units "reminded" it could capture settlers.
Bonus info: the end of the attack was also a bit odd, because if they had pushed a bit more i could have indeed lost the city. I guess they were losing too much units, and that was the reason they aborted the attack.
 
Even for a human it's often hard to move your units around in a proper way. Making sure vulnerable ranged units aren't exposed to direct attacks, not moving units into spots where multiple cities/encampments can focus fire, etc. I can understand that would be hard to program.
But AI not focusing fire to kill of one unit at a time, ranged units moving out of city/encampment for no reason, units embarking in front of your fleet, stuff like that shouldn't happen though imho.
Couple days ago Teddy attacked a city of mine. I had one archer present and no walls. He brought 4 archers and 3 warriors. He was so busy trying to get units into position for siege that I had time to build and bring more units and get a wall up and fending of the attack.
 
Even for a human it's often hard to move your units around in a proper way. Making sure vulnerable ranged units aren't exposed to direct attacks, not moving units into spots where multiple cities/encampments can focus fire, etc. I can understand that would be hard to program.
But AI not focusing fire to kill of one unit at a time, ranged units moving out of city/encampment for no reason, units embarking in front of your fleet, stuff like that shouldn't happen though imho.
Couple days ago Teddy attacked a city of mine. I had one archer present and no walls. He brought 4 archers and 3 warriors. He was so busy trying to get units into position for siege that I had time to build and bring more units and get a wall up and fending of the attack.

The thing that bothers me is I'd want the AI to set up a siege. They just need to be able to (1) avoid taking too much damage doing it (either by moving them from farther away or by giving better buffs), (2) damage the city while they're getting into place, (3) stay in place once they get the siege, (4) have enough units to maintain the siege. It's a tall order, though.
 
I vaguely remember the movie (yes, I did see it back in the day), but what type of situation are you referring to?
The scene where the police are about to catch him and are told to return to base because they are 6% overbudget
 
The thing that bothers me is I'd want the AI to set up a siege. They just need to be able to (1) avoid taking too much damage doing it (either by moving them from farther away or by giving better buffs), (2) damage the city while they're getting into place, (3) stay in place once they get the siege, (4) have enough units to maintain the siege. It's a tall order, though.
Also while performing a siege it would be helpful to bring a siege unit such as a ram or tower. It is very difficult to take walled cities without one.
 
The thing that bothers me is I'd want the AI to set up a siege. They just need to be able to (1) avoid taking too much damage doing it (either by moving them from farther away or by giving better buffs), (2) damage the city while they're getting into place, (3) stay in place once they get the siege, (4) have enough units to maintain the siege. It's a tall order, though.

Well, this was very early game obviously, if he had used his warriors to attack the city instead of circling around through the hills he would have taken the city. My city health was in the red when I got the wall up.
 
Civ 6's combat AI can be good at times, but indecisive at others. I know many of us here would prefer the AI to be better at combat, but how can that be done? I thought it might be nice to start a new discussion on this aspect of the AI.

Combat using the 1-UPT system seems to be more challenging for the AI than the previous stack-based combat, as it can't just toss a big portion of its units into 1 square and just move that stack towards its target. From what I understand from the modding DB in Civ 6, the AI plans attacks using "operations teams" that have minimum and maximum unit limits (divided by unit types), and have specific purposes (walled city capture, regular city capture, city defense, some others). In theory, these kinds of teams would be great. But this system may be making the AI indecisive.

Thinking through AI war goals, this is the basic algorithm I've come up with so far:
  1. Identify the key target (capital city, closest neighboring city, etc.)
  2. Form a large army to attack the target
  3. Gather them in one area
  4. Determine how to get to the city and which spots to take up
  5. Move towards the city and take up position
  6. Begin the attack
I've seen the AI form groups and begin to move them, only to hesitate. I think the AI is very protective of its units, to the point where if it thinks it might lose the battle it'll retreat rather than try to continue. This is good in some cases, but since the AI has yield bonuses (and I think production ones too?), maybe it could be programmed to be a little less protective.

I think removing walls (I saw someone suggest that), reducing city attack strength, or going back to vulnerable cities might be helpful. On that note, I once modded all units to have a large combat strength bonus vs cities, and a barb scout razed one of my cities :D That's probably taking it too far :) It was nice though to be forced to make units to defend my cities.

What are your experiences with the combat AI? Have you noticed it doing really well in the latest patch? Which of those steps do you think it's not doing well on, or is it focusing too hard on movement and leaving its units vulnerable to being picked off?

Since the last patch I've seen a huge improvement in AI tactical play - it's still not at the Civ V stage where it can appropriately target specific units with that unit's counter, it's poor at focusing fire on a single target and will often randomly ignore a damaged unit it could kill in favour of something else, but in most other ways pre-air combat it's approaching Civ V levels of competence (it still can't use air units and even though it builds fighters it doesn't often deploy them and often simply randomly rebases them. After more than 250 hours in Civ VI, I had a bomber damaged by a fighter for the first time ever yesterday).

The issue that prevented units firing out of a city that has walls has finally been fixed, the AI attacks with large enough forces at the start of a war and frequently a reasonable mix of ranged and melee, and if anything it's now better than Civ V at avoiding the 'sit and loiter while embarked/embark in range of enemy ranged units' issue. It almost always escorts settlers now, a perennial pre-patch problem. It's also improved at both building cavalry and using their speed to good effect; although late game unit selection still needs a lot of work (no more anti-tank spam, please, and please build support units and anti-air - if possible, code the system so that it can respond by building counters to whatever it's being attacked by) that's a separate issue from the AI's actual use of units. It needs to prioritise taking out artillery with cavalry, but doesn't seem to have any response to 3-4 range units coded, so although it can now put up a reasonably creditable defence in earlier eras it will just collapse in the face of artillery and bombers, often while it has technologically superior units.

The major flaws I now see are mostly strategic. It does seem to follow the algorithm you outline, but its target selection is still "rush the capital" by default, even when it's not the closest or easiest target to attack - that can give the player a very long time to see the attack coming and prepare. It also exhibits no ability at all to adapt to changing situations once it's committed to an apparent attack (Civ V had a similar issue to this latter, but it wasn't as pronounced). I started a session yesterday when America, my closest neigbour, sent 5-6 warriors towards me - I was far enough away that I responded by giving Teddy a money gift and declaring friendship with him, to buy time while I teched to Early Empire to prevent a siege. Teddy didn't quite know what to do after that, so the warriors just sat around St. Petersburg not doing anything. This became a problem when Washington fell to the Sumerians - the large American army that could have defended it vanished a few turns later when America's other city was taken, as the army hadn't even started heading back until Washington was captured.

In general it doesn't know how to defend - it garrisons more frequently than it did, but not exclusively, but while that makes early cities reasonably challenging to take (especially with the AI tendency to spam encampments) and the AI will either reinforce with nearby units or rush-buy units to defend, it won't bring units from further afield to help, just as in my America example. An AI can be losing cities left and right and still have a reasonably large military that's just scattered randomly across its territory.

The most obvious issues I've seen is that the AI often seems to 'forget' about units (I think when they fall outside aforementioned operations). I.e. settlers that have lost their intended spot just left frozen has been an example given.

It also continues to train settlers when there are no suitable spots left anywhere accessible to them.

It shuffles units around each turn seemingly at random while you mow them down like a turkey shoot, its beyond pathetic.

A human player should not be able to build a dozen units and go on an endless conquering spree, or defend with impunity, killing hundreds of units and keeping all/most of the dozen alive... If 1UPT can't be made to work for AI then Stacks of Doom in some form need to make a comeback as I'm just sick of broken combat AI at this point. I want to feel threatened... Games are over as soon as I've built a handful of units basically. Booooring!

The best approach there is not to play an aggressive game, unfortunately. I've done it for the domination achievement, but it's not my preferred strategy for that very reason.
 
Last edited:
AI still doesn't use ranged units placed in a city to fire on attacking units, they will just sit passively in the city center.
 
As an alternative to improving the tactical AI they could always restrict the player from doing things the AI can’t do. If the AI will only sometimes do a task, then have the player have only a chance of being able to do it. :crazyeye:
The player would have to be notified of the reason of the hiccup, of course.

In other words, dumb down the player rules/mechanics to match the level of the AI. This would be a substantial change from the current game, but as the AI is improved the player would have the corresponding change.

All in the name of fighting the AI on an even footing. :lol:

Enough of this silly post.
 
The AI civ now deploys planes on patrol rather than on the ground, probably why your bomber got hit.
They still tend to be passive as you say

I noticed - more remarkably, it later even moved the fighter to directly defend the city I was attacking. It took me aback because I had no idea how interception worked in Civ VI as it simply hasn't come up - the AI never attacks with air units and has never previously damaged mine. I just use flghters as glorified observation balloons, and occasionally to snipe ground units.

They should probably revert air units to Civ V rules (i.e. cities and many ground units have intrinsic AA defence and so they can be damaged or destroyed on attack runs) so the AI at least has a chance of taking them down. There are even graphics for tanks being attacked by planes using their pintle mounted AA weapons, but they deal no damage.

AI still doesn't use ranged units placed in a city to fire on attacking units, they will just sit passively in the city center.

That's not been my experience in recent playthroughs. The AI still won't always garrison, and when it does it won't always garrison with ranged units, but when ranged units are in place they'll now almost always shoot attackers.
 
I also think the ranged unit in the cities do shoot. I cannot verify that it shoots 100% of the time but it does shoot
 
It would be interesting to see an attempt to build a neural network that do the tactical fighting for the AI, i.e. strategic goals are set by an algorithm but the movements and attacks are handled by a neural network. Of course, it would not be an easy task to come up with an encoding of all options (as there are quite a few), but there should plenty of material to train the ai (existing games) and then let it play against itself.
 
A lot of interesting points :) Thinking about it, the city ranged strike can be a challenge for the AI to deal with, as can the new siege mechanic. Perhaps like @Jaybe mentioned some mechanics need to be changed/removed in order to give the AI a more reasonable chance at success. Right now when they attack cities, they have to deal with the player's units, the city's defense strength, the city's ranged attack, the city's healing (if not under siege), and any movement/positioning challenges. So they have to spend some time forming a team, decide to use it, deal with the challenges it takes to get that team in place, and then deal with all the above factors during the attack itself.

When we add all that to the "overbudget" mechanic that @Josephias and @Victoria mentioned, and add to it the "tunnel vision" that the AI sometimes has while on march to a target like @PhilBowles mentioned, it seems like the AI has a lot on its plate when it decides to siege a city. Removing the city defense and strength mechanics might actually help a lot. From what I recall from Civ 4 and before, cities had no strength of their own, and depended completely on their garrison. Attackers wouldn't take damage from an un-garrisoned city.

I'll keep experimenting with giving melee units city strength bonuses, some solutions can be tested using mods.

Couple days ago Teddy attacked a city of mine. I had one archer present and no walls. He brought 4 archers and 3 warriors. He was so busy trying to get units into position for siege that I had time to build and bring more units and get a wall up and fending of the attack.

Yup that's sadly something I've noticed too, positioning before they arrive would help a lot with that.

Since the last patch I've seen a huge improvement in AI tactical play - it's still not at the Civ V stage where it can appropriately target specific units with that unit's counter, it's poor at focusing fire on a single target and will often randomly ignore a damaged unit it could kill in favour of something else, but in most other ways pre-air combat it's approaching Civ V levels of competence (it still can't use air units and even though it builds fighters it doesn't often deploy them and often simply randomly rebases them. After more than 250 hours in Civ VI, I had a bomber damaged by a fighter for the first time ever yesterday).

The issue that prevented units firing out of a city that has walls has finally been fixed, the AI attacks with large enough forces at the start of a war and frequently a reasonable mix of ranged and melee, and if anything it's now better than Civ V at avoiding the 'sit and loiter while embarked/embark in range of enemy ranged units' issue. It almost always escorts settlers now, a perennial pre-patch problem. It's also improved at both building cavalry and using their speed to good effect; although late game unit selection still needs a lot of work (no more anti-tank spam, please, and please build support units and anti-air - if possible, code the system so that it can respond by building counters to whatever it's being attacked by) that's a separate issue from the AI's actual use of units. It needs to prioritise taking out artillery with cavalry, but doesn't seem to have any response to 3-4 range units coded, so although it can now put up a reasonably creditable defence in earlier eras it will just collapse in the face of artillery and bombers, often while it has technologically superior units.

The major flaws I now see are mostly strategic. It does seem to follow the algorithm you outline, but its target selection is still "rush the capital" by default, even when it's not the closest or easiest target to attack - that can give the player a very long time to see the attack coming and prepare. It also exhibits no ability at all to adapt to changing situations once it's committed to an apparent attack (Civ V had a similar issue to this latter, but it wasn't as pronounced). I started a session yesterday when America, my closest neigbour, sent 5-6 warriors towards me - I was far enough away that I responded by giving Teddy a money gift and declaring friendship with him, to buy time while I teched to Early Empire to prevent a siege. Teddy didn't quite know what to do after that, so the warriors just sat around St. Petersburg not doing anything. This became a problem when Washington fell to the Sumerians - the large American army that could have defended it vanished a few turns later when America's other city was taken, as the army hadn't even started heading back until Washington was captured.

In general it doesn't know how to defend - it garrisons more frequently than it did, but not exclusively, but while that makes early cities reasonably challenging to take (especially with the AI tendency to spam encampments) and the AI will either reinforce with nearby units or rush-buy units to defend, it won't bring units from further afield to help, just as in my America example. An AI can be losing cities left and right and still have a reasonably large military that's just scattered randomly across its territory.

I'm glad to hear the tactical play has gotten better! And that the AI is going to war with a better unit mix. You handled that situation with Teddy really well :D I'm guessing those warriors were part of a city attack team, and the AI didn't remove them from that team until it was too late. I wonder if reducing the number of teams of each type might help, or maybe allowing more city defense teams compared to other types. That might help with the issues you mentioned in the last paragraph too.

The strategic AI might be responsible for most of the issues we're encountering, hopefully they take another look at it soon.

The issue with capitals seems to be common, I've had two instances where I remember the AI gunning for my capital with enough forces to take it, but due to losses on the way and a beefier defense when they arrive, deciding to retreat or just hang around, causing more inevitable losses due to the city attack mechanic along with any garrisoned or otherwise safe ranged units. They could code them to attack the closest city to them. If they combine that with full dedication to take their target, even at the cost of losing 80% of their units, players would start to feel truly threatened. As it is now, with a few ranged units, I think most players feel safe enough to meet any invading AI army.

I think AI+ got really close to helping the AI actually commit to attacks, I'm not sure though how well it works with the latest patch, I know that issues with settling caused me to deactivate it for a while.

I wonder what would happen if units become much stronger but also more expensive. That might help a lot with the unit shuffling if the team unit limits are tweaked.

The AI I think will be a threat by the end of the Civ 6 cycle, and hopefully we can get it to be a threat through modding as well before then.

I noticed - more remarkably, it later even moved the fighter to directly defend the city I was attacking. It took me aback because I had no idea how interception worked in Civ VI as it simply hasn't come up - the AI never attacks with air units and has never previously damaged mine. I just use flghters as glorified observation balloons, and occasionally to snipe ground units.

That's great to hear! I'm trying to wait for Rise and Fall to play another game, but air combat always gets me excited to play. I still remember the fun and power of stealth fighters in Civ 2 :)
 
Last edited:
A lot of interesting points :) Thinking about it, the city ranged strike can be a challenge for the AI to deal with, as can the new siege mechanic. Perhaps like @Jaybe mentioned some mechanics need to be changed/removed in order to give the AI a more reasonable chance at success. Right now when they attack cities, they have to deal with the player's units, the city's defense strength, the city's ranged attack, the city's healing (if not under siege), and any movement/positioning challenges. So they have to spend some time forming a team, decide to use it, deal with the challenges it takes to get that team in place, and then deal with all the above factors during the attack itself.

That's why I think neural networks could be an interesting path for tactical gameplay. Sieging (or defending a city against a siege) is a complex task given all mechanics and possible options, but with quite well defined success criteria (city health), and quite simple way to evaluate a position (city health, unit strengths and health, encampment healths, etc). It should also be fairly easy to automatically generate a vast number of siege situations for the AI to learn from and siege and defend could be trained at the same time. Of course, some other part of the AI would have to control which city to siege, whether to siege or not, i.e. the strategic choices.
 
Back
Top Bottom