AI: Why is it so hard to improve?

I started playing the series at Civ III and it really doesn't feel like there's been much of a difference in AI capability. In the jump to 1 unit per tile in V you run into the problem with increased tactical control that while funner for the human player it becomes much easier to exploit and dominate the AI. Just compare Total War with Crusader Kings II a great example int he contrast.

The other thing to keep in mind when talking about AI for a game like Civ, it's not just that it needs to be good, but it also needs to be fast. How long the player needs to wait between turns has to be taken into consideration. You could make a powerful AI that plays the game really well, but if it takes an extra minute or two between turns on an average PC then it's a failure. I'm not sure exactly to what extent this applies here, but it's gotta be a factor.
 
The thing is, if the AI empires are anywhere remotely as aggressive as the barbarians, we would not have nearly as many complaints. They managed to make the barbarian menace real in the early game, proof that they can actually code an AI that poses a threat to human players. Why are the major civs' forces so comparatively shy?

Is it because the barbarians' sole purpose is to harass you? Is it because the AI for major civs have to juggle many other tasks? Do these even matter? Not sure why. But make the AI units all pillage-happy and not retreat-happy, and I guess we get a decently challenging combat AI.

Good point. I think you are right. The AI has to do other tasks apart from invading human players. And that raises a balance issue. Had it been an easy task so much so like molding the AI of barbarans into all the CIVs, 2K would have done so earlier. It msut be a sophisticated process and huge effort of coding and un-resolvable problems that hinder the implementation of such process.

I also imagine that there were some arguable items that divide the coding efforts, which at some stage broke up before the release. As a result, we have a product which posses of questionable AI capacities. And since there are possible modifications which will improve the said handicapped aspect of the game, 2K just leaves it to the modders, regrettably.
 
Good point. I think you are right. The AI has to do other tasks apart from invading human players. And that raises a balance issue. Had it been an easy task so much so like molding the AI of barbarans into all the CIVs, 2K would have done so earlier. It msut be a sophisticated process and huge effort of coding and un-resolvable problems that hinder the implementation of such process.

I half think this is true. Another half is thinking that the poor AI is a deliberate design. Because I'm not really sure why else they need to have two kinds of combat behavior coded in for the AI. If it is intentional to have weak AI though (like some people have quoted from Sid) then we are at the mercy of modders once again if we want a challenging AI.
 
The other thing to keep in mind when talking about AI for a game like Civ, it's not just that it needs to be good, but it also needs to be fast. How long the player needs to wait between turns has to be taken into consideration. You could make a powerful AI that plays the game really well, but if it takes an extra minute or two between turns on an average PC then it's a failure. I'm not sure exactly to what extent this applies here, but it's gotta be a factor.

Very much like my argument. Just like a teacher can create the most difficult questions in examination papers, but what's the point for that if 90% of students will be failed.

Besides, the publisher has to retain or maintain her reputations ever built-up for so long, she has to make decisions of what are to be prioritized and what are to be reduced. The end-product is what we have got.

I half think this is true. Another half is thinking that the poor AI is a deliberate design. Because I'm not really sure why else they need to have two kinds of combat behavior coded in for the AI. If it is intentional to have weak AI though (like some people have quoted from Sid) then we are at the mercy of modders once again if we want a challenging AI.

That makes my point.

Many many yearago, my colleague was introduced the Team Fortress game through me and he was always losing, hardly got one kill ever, and after 10 minutes he said he is not going to play the game ever again!

So the pyschology of players is like that in general, th normal distribuition curve.

What I am trying to say is that he is excused even he deliberately designed that, Sid has a strong reason.

According to the President recently, amazed that AI is taking over in a decade that more and more workers will be out of jobs. So how difficult would that be for developers to code a much anticipated AI for the game, factually. It's just how willing are they to accomplsih that.
 
Last edited by a moderator:
I tend to agree. A group of volunteers made a very competent AI for the Community Patch in Civ 5. I can hardly believe that Firaxis can't achieve the same if they put their heart into it. I only hope they can be convinced that a good AI is necessary for a lasting fanbase, though. I mean, I agree that a higher possibility to win will attract newcomers, but at the same time it dis-incentivizes delving into the deep mechanics since it is so easy.
 
I tend to agree. A group of volunteers made a very competent AI for the Community Patch in Civ 5. I can hardly believe that Firaxis can't achieve the same if they put their heart into it. I only hope they can be convinced that a good AI is necessary for a lasting fanbase, though. I mean, I agree that a higher possibility to win will attract newcomers, but at the same time it dis-incentivizes delving into the deep mechanics since it is so easy.

Well, if you look at the entirely changed graphics in the art department, the addition of card approach in the policies feature and the new CS engine which is impressively, different even from the community patch in CIV 5, you can immediately observe that Firaxis is positioning the product to suit newcomers, no doubt about it. As to retainning old fans, the publisher believes that if he stays, he is a fan, if not he is not a fan. The growth is more important. I bought CIV 4, then CIV 5 and quite frankly, I didn't play CIV 5 a lot at all initially, until recently, when all are stable, I begin to delve into it. Actually, I don't really care about the mechanics and detalied calculations of how hammer are put together as a function of happiness for instance. I just play it for the fun of it and what exactly do I enjoy? Well, I enjoy the thinking part of it that FPS games doesn't provide me with that much, nor RTS games do provide me with the same.

So for fans like myself which prefers the strategy part of the game, we will not leave. Just like chess players. How often wil you see a chess player lose his interest and leave the community for good? I rarely see one myself.
 
While I think you are right for the most part, Civ has a much steeper learning curve than chess. You want the AI to take it easy on them early, but also make them engaging enough so as not to be pushovers. Otherwise it's hard to both get into and stay in the game. There probably isn't really a sweet spot, but I think that if they are going to intentionally make bad AI, they should contain the AI to Chieftain and below.

It is great that they are trying to expand their fanbase - if the number of sales is any indication, they are succeeding so far. I just don't think they should deliberately sacrifice the AI for that purpose.
 
So the only logical explainations are quite clear now.

Most obviously, if an improved AI takes lots of processing power from an old fan playing it on a dated CPU, then one will most probably reduce the overhaul to a minimum, such that it can be sustained. There is an fairly old game called Falcon 4 which came out in 1999, but average desktop couldn't run it smoothly until 10 years later an average PC at the time could handle the loading part and its AI simulation component in a reasonable fashion. The AI simulates a full scale war-theatre within Korean peninsular and it's talking about hundred of warplanes in the air, thousands of ground troops on the ground with armor vehicles and conventional artillery apparatus as well as Naval Task forces in the Japan Sea. Endless missions are generated and plus and minus of battle outcomes are calculated. Also, graphics are top-notch consideration adding to it, the player is allowed to jump into the cockpit of an F-16 fully rendered avionics as well as detailed aerodynamics being implemented. One can see the game developers have the abilities to demonstrate how sophisticated routines can be implement and executed without performance degradation on high-end PCs, however not for the average performance desktops. So, for CIV games, I trust it's business decisions not to make the AI over-sophisticated to avoid players coming back complaining that the hardware requirements been so high.

Another possible logical explaination is intentionally leaving to the enthusiastic modders to do the rest of the job according to different flavours required. Can't please everybody can you? So having MOD A suits a population of the whole community and MOD B for another population of the community. Doesn't it sound more flexible and more choices are there for everyone!
 
(professional software engineer whose worked in AI for decades (among another other areas) FWIW)
Imo, none of the academic approaches you discussed are suitable for a game like civ5, where the time between turns has to be kept small despite a very large search space . Remember that it does not need to be optimal, simply fun and convincing. We are not optimizing the logistics of a multinational with a supercomputer, I would not go for a combinatorial approach.

Personally I would let the strategic analysis produce every turn a few high-level objectives (grab territory from X, focus on economic development), make them produce low-level objectives (conquer city X, city Y, etc) and score them. Then I would rank the latter and, starting from the best one, I would inspect the resources to do so (turns, units, units being produced, production turns, etc) and modulate the score by the costs of those resources. Then I would either commit the objective if it's still at the top, or lower it to first inspect alternatives, or discard it for this turn if no resources are available. O(n log n)

Every objective would then take care of the details with dedicated algorithms. For example the "conquer city X" objective would assign units (infantry at center, archers behind, within every group first assign farthest destinations with no closer units). O(n ^ 2) with little n.

As for tactical movement, on every turn I would rank all moves by ideal path length ignoring 1upt, then starting from the longest one I would recompute the best path with 1upt (no blocked tile for first unit moved), and block its destination tile for this turn. O(n log n * path finding cost). Far less if we recycle paths from previous turns.
 
Last edited:
The thing is, if the AI empires were anywhere remotely as aggressive as the barbarians, we would not have nearly as many complaints. They managed to make the barbarian menace real in the early game, proof that they can actually code an AI that poses a threat to human players. Why are the major civs' forces so comparatively shy?

Is it because the barbarians' sole purpose is to harass you? Is it because the AI for major civs have to juggle many other tasks? Do these even matter? Not sure why. But make the AI units all pillage-happy and not retreat-happy, and I guess we get a decently challenging combat AI.

They did a much better job with the Barbarian AI over Civ V, but I don't think it's really applicable in this context.

To put it simply, the Barbarians in VI have no sense of preservation, they are just aggressively suicidal. In V if you put an archer on a forested hill next to a brute, the AI will do a check see it loses the combat and not attack. And they always make sure there's a fortified unit protecting the encampment. In VI on the other it's not that the Barbarians are necessarily smarter, they're focus is simply attack attack attack!. They'll initiate losing combat and they'll always leave their encampments to go after you. In a way they're actually dumber, but in their stupidity more effective. Why? Because they're most prevalent at the beginning of the game when they have you outnumbered and when what few units you have matter the most. This is why they're dangerous, plus if a scout spots you and makes it back they can spawn that deadly horseman+horse-archer combo.

The AI Civ leaders could probably learn from them in some cases, but for the most part the same 'attack with reckless abandon' pattern the barbarians use would probably play right into the human players hands. Just fortify a strong position, let them go all Zapp Brannigan and throw wave after wave at you, and when their armies been chewed up you can counter attack and easily take their cities. The Civ AI needs to have some sense of self preservation for their units, and that's what makes their AI hard to do well.
 
They did a much better job with the Barbarian AI over Civ V, but I don't think it's really applicable in this context.

To put it simply, the Barbarians in VI have no sense of preservation, they are just aggressively suicidal. In V if you put an archer on a forested hill next to a brute, the AI will do a check see it loses the combat and not attack. And they always make sure there's a fortified unit protecting the encampment. In VI on the other it's not that the Barbarians are necessarily smarter, they're focus is simply attack attack attack!. They'll initiate losing combat and they'll always leave their encampments to go after you. In a way they're actually dumber, but in their stupidity more effective. Why? Because they're most prevalent at the beginning of the game when they have you outnumbered and when what few units you have matter the most. This is why they're dangerous, plus if a scout spots you and makes it back they can spawn that deadly horseman+horse-archer combo.

The AI Civ leaders could probably learn from them in some cases, but for the most part the same 'attack with reckless abandon' pattern the barbarians use would probably play right into the human players hands. Just fortify a strong position, let them go all Zapp Brannigan and throw wave after wave at you, and when their armies been chewed up you can counter attack and easily take their cities. The Civ AI needs to have some sense of self preservation for their units, and that's what makes their AI hard to do well.

I see your point. The AI leaders are somehow too self-preserving, and in a bad way. They would march within 2 tiles of your city, and upon receiving the tiniest damage, shuffle their units out. The AI forces still pretty much outnumber mine (unless I do nothing but produce units for a good few turns), and in theory should do well if they come at me with the bulk of its forces. The correct way to code self-preservation for the AI IMO is to make them less DoW-happy, and to save their forces until they have something significant before they actually attempt to attack. Right now they declare a war every 10 turns and nary have a unit that threatens me.

So yeah, the scout -> build up an army -> attack model of the barbarians, if applied to the AI leaders, would make them so much better than their faux self-preservation right now.
 
would probably play right into the human players hands. Just fortify a strong position, let them go all Zapp Brannigan and throw wave after wave at you, and when their armies been chewed up you can counter attack and easily take their cities. The Civ AI needs to have some sense of self preservation for their units

This already happens. (VI's AI dithering and caution just make it worse.) We don't need to make the AI avoid focus fire traps, we need to take focus fire traps out of the game: move battles to open field.

I'm repeating myself in these AI threads but I feel like after BNW there was a bit of consensus about this - "get combat out of the city and the player will be more threatened by AI and have to devote more resources to defense" - and now VI is out and we're all "let's ask those people who never made an AI that can take our cities to make an AI that can take our cities! It's sure to work because I like this patch that happened."
 
This already happens. (VI's AI dithering and caution just make it worse.) We don't need to make the AI avoid focus fire traps, we need to take focus fire traps out of the game: move battles to open field.

I'm repeating myself in these AI threads but I feel like after BNW there was a bit of consensus about this - "get combat out of the city and the player will be more threatened by AI and have to devote more resources to defense" - and now VI is out and we're all "let's ask those people who never made an AI that can take our cities to make an AI that can take our cities! It's sure to work because I like this patch that happened."
I doubt there is any consensus about this. And if "get combat out of the city" works like how I am picturing it, then I can raise plenty of reasons why it is a bad idea, although that probably belongs in a separate thread.
 
Its a problem of coding the AI to have "personality", and with how it determines some basic stats.

Really, how much they like/dislike you should be less of a factor in them figuring out if they DoW. It should be: does DoW accomplish its projected goals?

The AI should cheat, it should just have full map information, it should have a projected idea of each city it needs to win, adjusted based on difficulty and what the other players do. Hence a DoW is completely valid if the AI needs to burn a city down or take it over so it has the right margin to win.

I think like/dislike is a fine mechanic, but they should not DoW no matter how much they dislike you if you're stronger, and they can't knock you down a peg. OTOH, if they trust you... that might allow for alliances, and they might be fine so long as you don't get in their way.
 
What Sid said actually doesn't matter at all. He was there when Civs I to IV were difficult, and he didn't care. He was right there in the year 2016 when Firaxis released XCOM 2 which is hard on the highest level and he didn't care. IMO the designers of Civ 5 and 6 had as much free reign as the designers of Xcom 1 and 2 when it came to difficulty levels.

...
Yet actual difficulty has tanked greatly which is attributed to 1UPT.

Sid being there in the background is the whole problem and depending on the amount of his "guiding influence" he was able to transfer the difficulty varies. Another example for that are whack-a-mole mechanics. It got massive in Civ3 (pollution, and units could only be moved individually, a stack of 20 units? good luck). Due to the public outcry these "features" were removed in Civ4... only to be reintroduced in Civ4BTW in form of spy "sabotage" and corporation spam, which transferred well into Civ5/6 in form of AI missionary spam, and the player having to counter spam. So obviously there is someone there in the background, thinking turns in Civ should be made of mindless clicking and AI not doing anything. Remember Civ5vanilla was pretty aggressive, and then dumbed down in Civ5bnw.

1UPT? Please, it does not forbid the AI to create more than 3 cities, which i experienced Scythia to do for no reason in my last game. Sadly it does appear to be a deliberate design choice.
 
I can't speak for Civ6, but it was trivial to make a mod in Civ5 that made the AI *hard*, (I did so myself simply by nerfing the player tech rate and having AI units start with lots of promotions) but making the AI *smart* was another thing entirely. I haven't played Civ5 in a long time, so I didn't realize VP = community balance. As it turns out, I have played it, or at least the version that was out back then. It suffers from the same problem I have with Deity Civ5. I don't want an AI that's hard because it's super-buffed. I want an AI that's hard because it makes good decisions. And that wasn't possible with the modding options available in Civ5. Maybe it will be in Civ6.

Also, this whole argument about making the AI dumb on purpose is missing the point. I'm not asking them to make Prince hard. I'm asking them to make Deity hard. You wouldn't be alienating the playerbase by making Deity hard. However, it is a valid point that since such a small percentage of players play on Deity, it's not cost-effective to develop for it. :p
 
Maybe this is a silly question, but does the AI do any work on our turns? If not, why not?

I know that combat would have to wait until the AI's turn, but what about decisions such as build orders and tech choices? Most of those decisions are made mostly in a vacuum, or at the very least, would only be 1 turn behind on the logic.

I imagine that would need to be a design decision from the start, but IMO, if you could offload some of the AI decision making to the time we use on our turns, that would give more time for strictly combat related processing.

Just trying to think outside the box, assuming it is not already done that way.
 
I'm a long time 4X player, I started with Civ I soon after it came out. I wouldn't call myself the best in the game, but I do generally do well on the hardest levels in different games, for example the AoW III that was mentioned earlier on.

That said, I have played the Pandora with the AI that AIL programmed, and it is, without doubt, the most competitive AI I've ever seen in a strategy game. I'd love to see his work on CiVI. I'd probably start playing it on Warlord.
 
Maybe this is a silly question, but does the AI do any work on our turns? If not, why not?

I know that combat would have to wait until the AI's turn, but what about decisions such as build orders and tech choices? Most of those decisions are made mostly in a vacuum, or at the very least, would only be 1 turn behind on the logic.

I imagine that would need to be a design decision from the start, but IMO, if you could offload some of the AI decision making to the time we use on our turns, that would give more time for strictly combat related processing.

Just trying to think outside the box, assuming it is not already done that way.
No, not possible.
 
The Sid quote mentioned before isn't related to "bad" AI. I would think that it's a lot more related to stuff like the random events we had in earlier games. When you get a boost from the event, nobody complains. But when your library is destroyed by a volcano, it feels like the game it out to get you.

Soren Johnson also had a great talk at Google you can find online where he talks a lot about the theory of AI, and it follows a similar principle - it's better to have the AI act logically but stupidly than to have the AI act like a human. That's why you had cases there where if you were friends with your neighbour, even if you had literally 0 units in your territory, they still would not declare war on you, because their agenda in that case was peaceful. Civ 5 took a different path, where they would follow the rules of the game too much, and your best friend would invariably declare war on you mid-game to stop you from winning. Civ 6 looks like it's more along the lines of civ 5 in that they're more aggressive, but the leader agendas are there to kind of bridge the gap. But obviously the weighting isn't quite right.

However, I feel that that sort of AI programming is very different than the simply bad AI that you see. So not upgrading units, not researching techs, constant shuffling of units, etc... are simply moves that are bad, and need fixing. So if Scythia only settles 3 cities, if you can see a "reason" for that in game logic (ie building wonders), I am much more understanding of that. But when she settles 3 cities and has a settler sitting in her capital that she doesn't do anything with, I have a problem with that. Or if she has an army that's all horsemen, okay, that's the flavour, even if it's probably not an optimal army. But if she doesn't actually use them to attack, and simply keeps wandering around with them until I pick them all off, that's a stupid move. I'd rather have the AI just shout "For death and glory" and proceed to suicide against me more often - at least there's a flavour to that, and if I still win, then great.
 
Top Bottom