How weak is the AI?

I'm mostly hoping that the royale will show off some proper AI tactical decision making. That is probably the hardest thing to get right, yet the easiest to observe and what will make the most impact in terms of feeling like the AI is competent. Empire building mistakes can be easily compensated by bonuses, war not so easily. You'll get unfairness feelings much quicker with combat bonuses than with production bonuses, because what happens in combat is just so much more visible. It's also almost certain to be impossible to mod tactical combat until we get access to the source code, while empire building related problems could potentially be fixed by the community and/or patches.
If the AI manages not to dance around, and we see it maneuver terrain (especially choke points) properly and if it manages to correctly position and use range units, then we can expect good things!
 
True...but that shows the idea (as well as showing that there is a lot of room for improvement)
Well, surely weighted decisions with priorities algorithm looks the best for most strategic decisions in civilization, but there are other simple AI algorithms like decision tree, which could be used for parts of the strategic AI. And I should say tactical AI is quite different beast.
 
I'm mostly hoping that the royale will show off some proper AI tactical decision making. That is probably the hardest thing to get right, yet the easiest to observe and what will make the most impact in terms of feeling like the AI is competent. Empire building mistakes can be easily compensated by bonuses, war not so easily. You'll get unfairness feelings much quicker with combat bonuses than with production bonuses, because what happens in combat is just so much more visible. It's also almost certain to be impossible to mod tactical combat until we get access to the source code, while empire building related problems could potentially be fixed by the community and/or patches.
If the AI manages not to dance around, and we see it maneuver terrain (especially choke points) properly and if it manages to correctly position and use range units, then we can expect good things!
I agree. It would seem that we will likely learn quite a bit about the AI's functionality from the royale on the 19th. Fingers crossed it won't be as bad as I currently believe it may be.
 
Well, surely weighted decisions with priorities algorithm looks the best for most strategic decisions in civilization, but there are other simple AI algorithms like decision tree, which could be used for parts of the strategic AI. And I should say tactical AI is quite different beast.

True, but even if a decision tree like system is chosen over a purely weighted model, it is likely to still base the decisions of the tree on values that can be easily set in configuration files. The civ teams have released a lot of content outside of the main game, like little scenarios with their own tech trees, and they're not going to create entirely new AI systems based just on that. They need a system that can be configured easily to fit new tech trees, new government options, new buildings, etc. And likely this'll be possible for those who didn't actually write the AI, as they'll probably use different people. The AI core programmer is unlikely to be the one who ends up setting all of the config values for all the scenarios.

And considering both civ 5 and civ 4 have used these weighted models (I'm not sure about earlier installments), I think I feel pretty secure in saying that civ 6 and probably most future civ games will also use very similar systems.
Which would mean were probably stuck with AIs that have rather similar skills in terms of empire building as the ones we have now. Hopefully it'll be better tweaked, and hopefully some of the systems will be offloaded to more specific systems that can allow 'planning', but I'm not expecting too much. I fear that the AI will be rather weak when it comes to chasing eurekas and placing districts for example.
The tactical game is where were likely to see the biggest gains, this is the most visible aspect of AI, they had more complaints about it, and its probably the easiest part to make significant gains in.
 
True, but even if a decision tree like system is chosen over a purely weighted model, it is likely to still base the decisions of the tree on values that can be easily set in configuration files.
I didn't dive deep into the AI code for Civ5, but isn't weighted model lacks decent planning capabilities? The tactical AI surely uses some kind of "targets", do you know whether strategic AI has anything like this?
 
I didn't dive deep into the AI code for Civ5, but isn't weighted model lacks decent planning capabilities? The tactical AI surely uses some kind of "targets", do you know whether strategic AI has anything like this?

Do you mean strategic as in who to declare war on?
If so, the standard war declaration model uses a couple of weights too and isn't based on a plan like 'I want city x'
It's basically a mix of: 'what is my personality', 'how much do I like civ x', 'am I already at war with someone/planning a war', 'how close is civ x', 'what is my relative military strength compared to civ x', 'am I on the conquest grand strategy', 'do they have nukes', 'are they a reckless expander', 'what is the difficulty level (prince and above all have the same)'.
It loops through all of the civs, and for each combines these factors using weights and if that combination of those factors hits a certain threshold, the AI will go into a war planning phase towards the civ with the highest score. When it prepares it will do a 'call to arms' where it collects all units in a certain area, puts it in a formation, moves it over, then declares war when its close. You can see this in game sometimes as the 'sneak attack' spies tell you about. During the preparation phase, the AI can still change its mind, which is especially common with distant civs, hence the phantom sneak attacks.

War can also be declared by someone asking them to, which uses hardcoded weights rather than xml weights and a completely different method. Whether a player asks and/or accepts is determined by:
'Do I like the person asking', 'do I like the target', 'am I not already in or planning a war', 'whats my personality', 'am I on the conquest grand strategy', 'is the target a warmonger'
So significantly less factors.
And lol, it appears I just found a bug, because its written so that the AI will be less likely to ask for a joint war if trade is happening, but instead of checking this for the player it is targeting it checks for the player it is asking. So its less likely to ask if it is trading with whoever he would've wanted to ask. This actually doubles up in effectiveness too, because whether a civ accepts is also impacted by the same thing. I guess that explains why the civs that declare together seem so random and why it's almost always some random civ across the globe that bugs you about declaring war.

In these types of joint declarations, the AI also won't wait for the 'call to arms' before declaring. And might never end up sending any forces.

On top of these systems, there's an additional weight based system that checks whether they will offer or accept peace and at what cost. This again uses different weights, most of which can be set through xml.

Because you basically have 4 different systems which all work with different weights: do I declare war myself, shall I ask/accept to declare war together, shall I offer/accept peace, shall I launch an attack force; you sometimes get funny results like war declarations not being followed up by attacks, or civs that declare war and will then offer everything for peace asap (there's a fixed timer).
 
Last edited:
First, Thanks so much, Siesta Guru, for your very informative peek at CiV AI. Enjoybale to read!

Why is the AI so bad at choosing where to settle?
Because:
CITY_RING_1_MULTIPLIER 6
CITY_RING_2_MULTIPLIER 3
CITY_RING_3_MULTIPLIER 2
SETTLER_FOOD_MULTIPLIER 15
SETTLER_PRODUCTION_MULTIPLIER 3
SETTLER_BUILD_ON_COAST_PERCENT 40
BUILD_ON_RIVER_PERCENT 50
SETTLER_EVALUATION_DISTANCE 24

It considers a tile next to the city 3 times as important as a tile 3 tiles away. And it considers food 5 times as important as production. A single point of extra food next to the settle location is 15 times as important as a point of production further away. And worse, the total bonus of a new luxury resource appears to be about ~30ish. With the multipliers a single food yield 1 tile away gets 90 points, a luxury 3 tiles away gets 60 points.
On top of that, it will boost the value by 40% if the city is on a coast and by 50% if its on a river.
A grassland spot next to a single piece of coast (11 food points) on a river is going to handily beat 6 plains salts on the third ring in terms of importance. Even despite it counting the happiness impact of the salt six times.
Coast grassland: 11*6*15*1.4*1.5 = 2079
Salts: 30*2*6 (happiness/resource impacts) + 6*2*15*2 (food values) + 6*1*3*2 (prod) + 6*1*3*2 (gold) = 792
Look around in your games and check how many of the AI cities,and how many of recommendations are placed on river-coast spots with lots of grass around.
The Civ 6 unstacking of cities will really cause a significant change to this area of the AI. Will be interesting to see the AI in action :)
 
I was speaking about the whole strategic level - techs, policies, building things.

Anyway, as described, the AI uses "states" as "war planning phase", which is the most basic form of planning. That's ok :)

Yeah the war preparation phase is definitely a form of planning. There's also some things like deceit put in there so that they'll hide their intentions. The normal war declaration and general attitudes towards players feel like some of the more sensible AI systems in game, although some tweaking would be nice (its weirdly sensitive to rapid expansion and not sensitive enough to players having no military).
The joint war system is sadly terrible though. I didn't expect it to actually contain a major bug, but I think most players can agree that those declarations felt very random.


In terms of techs/policies/buildings/units, there's very little on top of of the flavor system and very little I would consider planning ahead. There is absolutely 0 regard for requirements, and a lot of complex mechanics have been reduced to simple flavor values. A real player thinks about the amount of marble/stone he has when considering the Mausoleum, an AI just has flavor_gold. Even the worst of real players wouldn't build navy in preparation for a war with a landlocked player, an AI just sees flavor_offense and flavor_defense on navy units and builds them.

But, some of the flavor system reacts to changing environments and is in that sense intelligent. Being on a naval map increases the desire for naval, there's a boost to expansion at the start of the game, that kind of thing. Sadly there's not that many of these though.

On top of that, looking through the actual code now, I can find these intelligent behaviors on top of the flavor system
- It does do city specialization based on intelligent factors. This impacts flavors. On top of that, there's a designated wonder city. Other cities don't build wonders. And there's a randomness based system in place that stops them from going 100% into wonder production.
- It can recommend units of a certain type if it needs to fill a certain formation up. As in, we're going to siege a city, we don't have any siege units, lets build a catapult. As far as I can tell this happens rarely though.

The religion picker system works differently from units/buildings/policies/techs and appears to be one of the better systems. It actually calculates the extra benefit every religion gives in terms of increase of yields inside of its empire based on the benefit to tiles/cities. Then out of its top 3 choices, it picks one. The only weird things here are is that happiness is dramatically undervalued, and that I don't think they really realized that the formula used massively overvalues the benefit of the city bombard damage boost pantheon, which will probably always be in the top 3 picks.
 
Last edited:
What if the AI, in addition to having preference values for building flavors, also had preference values for specific buildings?

For instance, Tomyris may only want a Domination victory, so she'd prefer to make only buildings with a high Military flavor. But she, like all AIs, would have a high preference value for building a Science District, so as soon as she runs out of Military-flavor things to build in a city, that'll be the next building she focuses on.
 
What if the AI, in addition to having preference values for building flavors, also had preference values for specific buildings?

For instance, Tomyris may only want a Domination victory, so she'd prefer to make only buildings with a high Military flavor. But she, like all AIs, would have a high preference value for building a Science District, so as soon as she runs out of Military-flavor things to build in a city, that'll be the next building she focuses on.

That's possible even within flavor based system through adding one-use flavors that boost only one building, unfortunately that wasn't possible in civ 5. Creative use would be a great tool in promoting better strategies and more flavorful leader strategies.
It'd be great if they made use of this or allowed modders this ability. You could for example make a civ specific flavor that you slap on ancient/classic science buildings, medieval production/military buildings, some techs to beeline in renaissance and then on some units of that era. That would encourage behavior we'd think of as planning for a renaissance era assault, while still allowing some flexibility if the map doesn't allow for it or something.
It would appear to us like planning and proper strategizing, even though it uses the same flavor system.
 
Weighted system is actually quite powerful, as there's no limit how complex the parameters are. For example, it's possible could calculate "naval exposure" (like the percentage of naval cities from the total amount of cities) and use it to favor building naval/land units during war preparation.
 
Naval = (Civ-specific weighted constant) * (number of water tiles within workable radius of own cities) / (total number of tiles within workable radius of own cities)
 
Weighted system is actually quite powerful, as there's no limit how complex the parameters are. For example, it's possible could calculate "naval exposure" (like the percentage of naval cities from the total amount of cities) and use it to favor building naval/land units during war preparation.

Agreed. Unfortunately they're just as powerful as they're made to be, and no more. And in the case of Civ, the answer, unfortunately, is usually "not terribly."
 
Agreed. Unfortunately they're just as powerful as they're made to be, and no more. And in the case of Civ, the answer, unfortunately, is usually "not terribly."

Yeah that's right. A weighted system is definitely one of the best ways of doing this kind of thing, but if most if your weights are 'dumb' as in 'not responding to the environment', and if many of the weights are weirdly tweaked, then you end up with players that barely manage to get anything done.
I've done a bunch of flavor tweaking for a balance/ai mod Ive been working on for a while, and the AI actually ends up being a beast (at emperor+) with proper weights and less lopsided balance. T300 domination victories in battle royales, that kind of thing. And that's using just the 'dumb' preconfigured flavors, without being able to resort to more intelligent stuff like weighting certain civs to prefer good strategies.
 
Yeah that's right. A weighted system is definitely one of the best ways of doing this kind of thing, but if most if your weights are 'dumb' as in 'not responding to the environment', and if many of the weights are weirdly tweaked, then you end up with players that barely manage to get anything done.
I've done a bunch of flavor tweaking for a balance/ai mod Ive been working on for a while, and the AI actually ends up being a beast (at emperor+) with proper weights and less lopsided balance. T300 domination victories in battle royales, that kind of thing. And that's using just the 'dumb' preconfigured flavors, without being able to resort to more intelligent stuff like weighting certain civs to prefer good strategies.

The optimistic part of me says, "Yeah, let's keep showing them what's possible, and one day a game will ship with great AI!" And then another part of me says, "Or they'll just keep leaving it up to modders." :blush:
 
I agree. It would seem that we will likely learn quite a bit about the AI's functionality from the royale on the 19th. Fingers crossed it won't be as bad as I currently believe it may be.

I don't think we will see much. You only get to see how bad the AI truly is when you let it play against a human player. If you pit weak AI against weak AI it will all look on par. Especially if the weakness is on the strategic side (slow teching, unit upgrading, diplomacy,...)
 
Top Bottom