Resource icon

AI+ v13.1

Siesta Guru

Prince
Joined
Dec 2, 2007
Messages
498
Location
The Netherlands
Update: Now compatible with Gathering Storm

Hi, this mod will be an ongoing project that attempts to make the Civ VI AI more competitive.


During this project I'll try to maintain the following points as a design philosophy:
- Stick entirely to changes that only impact the AI without impacting the larger game.
- No changes to the AI difficulty bonuses
- Improve the AI's ability to win without using cheesy strategies that reduce game enjoyment, such as all players declaring war on the player the moment they meet him.
- Maintain and improve upon the 'flavor' of the AI through distinct personalities and playstyles.


Changes

- The ability of the AI to wage aggressive wars. They will get more troops in faster and will use them more effectively. It won't be as distracted by enemy units, will not retreat as fast, will stick more to clustered formations and will be significantly less likely to stare your city down. It will also keep the pressure up throughout the entire game, with it now capable of capturing lategame walled cities. Occasionally you'll see a civilization completely take over another.
- Settle behavior, it now settles more appropriate locations at faster rates.
- Tuning on the AI's production choices. With extra changes based on whether it's at war, or under siege. Whether it has a religion, what difficulty setting we're on, etc. Overall you should see the AI develop larger, better cities, without neglecting their military.
- Leaders now have more distinct personalities when it comes to district/building/unit/etc choices.
- Many other small improvements.


Limitations

There's unfortunately a few strong limitations on this work. The worst is of course that we have no access to the game code, so most of what I can do is working within the system that Firaxis designed. This offers some flexibility, but there's many areas I just can't touch at all like many of the finer details of combat behavior, policy choices, repairing improvements, unit upgrading, agenda logic and much of the diplomatic system.
On top of that, testing changes out takes extremely long, so changes will be slow.
Any feedback on AI behavior and balance both with and without this mod is greatly appreciated. Especially when it comes to the later eras, slower gamespeeds, water maps and difficulties below prince.

At this point, the AI feel will definitely feel more solid than that in the base game, but still comes nowhere close to being on the level of actual players. I'd say it's now on a level similar or slightly higher than the unmodded Civ V AI, with different weaknesses and strengths. However, since the AI bonuses are much lower in Civ VI, the game will probably still feel easier.

Changelog
(The exact values and tweaks are way too numerous to name here and can be found in the files)

Spoiler :

Version 13.1
- Fixed compatibility with vanilla + R&F

Version 13.0:
- Made compatible with Gathering Storm
- Small District building changes
- Added unique behaviors to the new Gathering Storm leaders

Version 12.1:
- Small boost to commercial and campus districts
- Small reduction in unit production desire

Version 12:
- Made fully compatible with the expansion (and it should still work if you don't have it)
- Added unique behavior (build preferences etc.) to all the expansion and DLC leaders
- Deepened the uniqueness of unique behavior, militaristic civs are now more likely to attack, industrial civs will now prioritize techs like apprenticeship, etc.
- Reduced early city state rushes somewhat through making city states build more units early
- Tuned aggression a little. Average aggression should be about the same as in vanilla, but there should be some more focused aggression (when a civ feels strong, militaristic civs, more lategame wars, higher difficulty levels)
- Reduced late game settling somewhat
- Made some changes that hopefully reduce civs eagerness to make peace
- Removed some a change that made units less careful, as it's no longer needed for the AI to conquer cities.
- Slightly changed what civs prioritize econ wise due to changed balance


Version 11:
- Summer patch fixes, mostly expansion and war behavior related

Version 10:
- Made compatible with the Australia patch, including the new aircraft behavior
- Removed all game changing effects as they weren't necessary anymore
- Removed some settling behavior tweaks that were now decreasing performance
- Some parameter tuning, among which increased aircraft and campus desires

Version 9:
- Significantly increased AI ability to take both unwalled and walled cities through the following changes:
- They get much less distracted by enemy units and don't run all over your territory
- They won't retreat nearly as fast
- They'll now usually bring the correct siege weapons necessary
- Fixed a bug that made it very unlikely for late-game city attack operations to start.
- These changes mean civs will now occasionally end up completely taking over entire other civs and can sometimes take lategame cities.
- Changed some problems with low settle-speed in v8
- Reverted the change that allowed barbarian scouts to take civilians as it was affecting AIs way too much
- Further rebalancing on building priorities etc.
- Made it so they end up slightly friendlier overall (without decrease in wars, just slightly more green faces)
- Made fully compatible with the winter patch


Version 8:
- Large changes to how production desires work after realizing a flaw in earlier versions. This'll make the AI adjust to some aspects like war/peace much better.
- More districts and better early game religion rush compared to previous versions
- Amount of cities settled made more appropriate, especially for prince and below
- AI less likely to retreat its combat units
- Solved some issues with settler behavior, resulting in faster settling
- Made some minor alterations to late game city strength and barbarian spawn rates, as AI was affected extremely hard by this. If you're not a fan, delete the contents of gamechanges.xml

Version 7:
- Split faith and great prophet desires in three categories. Having a religion, being able to get a religion, and not being able to get a religion. The desire for it while in a religion is comparable to the base game, while the desire without a religion is significantly lower.
- Additionally altered faith desires on a per-leader basis
- Improved desire for districts back up to normal levels
- City States can now build districts other than their respective type
- Minor improvements to settler escorting (it'll still be bad)
- Settler production rates made more appropriate for standard speed, rather than quick.
- Tweaks to willingness to declare war on city states (they're now less likely to declare war in city states they are influential with)

Version 6:
- Fixed the 'no theatre districts' issue
- Small fixes/tweaking improvements

Version 5:
- Better terrain improvement
- More trade routes
- Reintroduced long distance strikes for civs on islands. (land-unit based)
- Added new 'expansionist' civs (England, Spain, Russia, Brazil, Scythia) on top of the vanilla Rome.
- Added Brazil and England to cultural civs (on top of the vanilla: France, Greece (both leaders), Kongo, America)
- Added Sumeria to the scientific civs (see older changes)
- Added Spain to the militaristic civs
- Added France as a wonderbuilder (next to vanilla China)
- Most of these archetypes are still only light changes right now, but will become more pronounced when I get a good feel of them.

Version 4:
- Made Settlers less indecisive, so that they'll settle down earlier
- Improvements to behavior while under attack, both tactical and through building choices
- Fixed some settlespot evaluation problems (forests and resources were considered too desirable)
- Increased desire for improvements and farms.
- The AI now no longer engages in very long distance wars.

Version 3:
- Hotfixed AI settlers not settling

Version 2:
- Improved AI's military offensive capabilities by a lot. It should send bigger troops faster, spend less time doing nothing, will be less scared and will feel overall more dangerous.
- Lots of finetuning in production choices. There should be a better balance between troops/districts/builders/etc
- A small start on individualization of civs. Some are now marked as militaristic (Sumeria, Gorgo, Norway, Scythia, Rome, Germany) and some as scientific (Germany, Japan, Arabia, America, Russia), and will prioritize these areas somewhat.
- Tech choices system improved slightly. It used to beeline towards techs that really weren't all that beeline worthy (like bee-lining for castles, without then actually rushing Alhambra)
- Minor alterations of preferences between different difficulty levels. On deity/immortal AI's have more time for wonders for example, while below king, AI's should limit their settling a little.
- Small improvements on settling behavior (higher preference towards settling on fresh water)
- Less siege weapons for city states
- Incorporated some of the more essential changes made by Delnar Ersike

Version 1:
- Big changes to settle behaviour. You'll find the AI will settle more appropriate cities in more competitive amounts.
- Overall improvements to building and district prioritization.
- Larger differences in building behaviour between war and peace. Less settlers/wonders at war!
- Small improvements in the AI's ability to wage an aggressive war.
- Instantly breaking the first design philosophy point, the war penalties have been made flatter so that the AI actually declares war sometimes in later eras.
- More warlike behaviour if the AI thinks it is strong.



Other mods and compatibility

Please note that this mod can end up behaving badly with other mods that impact the AI, and mods that impact some game aspects like production costs. In most cases though it'll cause small problems at most.
This mod already includes some of the more important fixes made by Delnar Ersike in Delnar's AI Cleanup and I would for now not recommend running them together.

Some mods that you may find worth considering that can help make the game more difficult as they help the AI play a little better:
- Smoother difficulty by RushSecond
- Strategic Resource and Tech Tree Rebalance Mod by Novemberisms
- AI Siege Help by Gort
- Quo's Rocketboots by isau




Install instructions:

Make sure you have at least the Australia patch installed (older versions won't work), then get the v13.1 of the mod here through Steam:
http://steamcommunity.com/sharedfiles/filedetails/?id=878717347

Or if you prefer getting it through civfanatics:
AI+
or here:
https://www.dropbox.com/s/jj427oiprr4jfyb/AI+ 13.1.rar?dl=1



To install, unpack the file into:
My Games/Sid Meier's Civilization VI/Mods
(So that it now contains the folder AI+)
Then launch the game, select Additional Content and enable AI+. The next time you launch your game this mod will be loaded. I wouldn't recommend loading old games if you install or update this, it can cause crashes.

To update from an old version, make sure to close the game completely first, and then disable/enable AI+ again after replacing the files.
 
Last edited:
I look forward to testing this keep up the good work. The tactical AI seems to be the main problem. In one of my games the operations AI built up a great and effective invasion force. Only to have the tactical AI start randomly moving them around in circles and not fighting back while I gummed them to death with my pathetically weak army...
 
Funnily enough that particular example actually seems to be more of an operational issue that looks a lot like a tactical problem. One annoying problem I've noticed is that the operation AI tells the force to get all of its units within a certain distance of a target. If that happens to be impossible because of one of many potential reasons, the AI can get 'stuck' in that move order. If the force is too big, it may not actually be able to get all of its units within the acceptable range. There's something in there that makes them still attack units meanwhile (doesn't always seem to work), but not cities. So yeah, they'll just keep standing there.
A similar issue is when the targeted city belongs to someone they're not at war with, the units will seem to amass borders as they try to move in close enough. The latter usually gets solved because the operation also tells the player to declare war, but theres some waiting time involved there.
If the borders are close, some of the units of the 'invasion force' that you see standing around are actually flagged by the operations systems to be part of a city defense squad or may be waiting for a settler to do a settler escort.And they just happen to be visible.

It already gets a lot less frequent with a few number tweaks, but significant changes are necessary for behavior that is actually solid. Currently working on that one. For now those mentioned tweaks are not in v1 because I've found some unanticipated negative side effects too that also need fixing.
 
Last edited:
I like your plan and goals a lot! This sounds like a very difficult task.

How do plan to do the testing?
1.) Is it possible to load a certain state of the game (save game file) with
a.) Vanilla Civ6 and
b.) your mod
and then compare?
2.) Is it possible to see the missions / operations of individual units?
3.) Is there debug output which helps you judge in which node the AI currently is?
 
Want to throw this on github and we can play with it a bit more?
 
I like your plan and goals a lot! This sounds like a very difficult task.

How do plan to do the testing?
1.) Is it possible to load a certain state of the game (save game file) with
a.) Vanilla Civ6 and
b.) your mod
and then compare?
2.) Is it possible to see the missions / operations of individual units?
3.) Is there debug output which helps you judge in which node the AI currently is?

So far I've done most testing battle royale style, with some in person games in between. Just observing what they're doing wrong works fine when it comes to most behaviors. The logs are helpful for more detail. There's a couple of nice logs that show what strategies civs are following, what operations they're launching (And which units are on them), what commands units are following, some diplomacy stuff, what they're building, details on the 'behavior trees' which is the internal execution of operations, and some others.
You can indeed load saves and apply the new behavior to those save games and do comparisons like that. I've not done so myself yet, but it's definitely a good idea, especially for the later eras.Not entirely sure what it'll do if it's in the middle of operations that have been changed though

Want to throw this on github and we can play with it a bit more?

Sure, let me get back to you on that one. Meanwhile you can just look at the xml files within
 
Last edited:
Have you been able to look up anything from the AI_*.log files by player ID yet?

If so, how? GameInfo?
 
I've been able to use the AI_ .csv files, but don't think I did anything in particular to make them work. No .log files with the AI_prefix though

Make sure to at least set:

AI_MasterLogging 1

In useroptions.txt (my games/civ 6)

If that's not enough, it may have been the changes I did to get the battle royale system to work with the civ 5 firetuner, someone else put a guide up somewhere on the forums.
 
Sorry man. I meant AI*.csv I'm looking to access those rows runtime. I assume they are in the db somewhere. Thus, they should be accessible via lua with the intention of showing some important rows in a Mod overlay.

I get output in the AI*.csv files.

I'm trying to find a way to do something like GameInfo.AICityBuild[playerID]
Or something similar to access the runtime db rows which correspond to the csv output. Know what I mean?
 
Ah got it, that would be extremely helpful indeed. Haven't really looked at the lua ye, but I wouldn't be surprised if they're not in the DB though. The csv entries are written directly to it during runtime (sometimes it doesn't log anything for the first turns if you have accidentally locked the files by opening them).
Don't see anything in the schema either that would suggest this goes to the database.
 
Agreed. I'm looking a bit in the exe to see if I can decipher where they mash together the csv info from. I'm not very good at reading assembly, but I'll let you know if I find something.

My assumption is the DB table is created at runtime. The csv files and values are very similar to the DB values in the AI tables, and the other information turn, playedID, etc are the same types of values as stored in the DB. This leads me to believe that we'll be able to find them if we know the table names.
 
Well, i don't know what to choose beetween this one and Delnar AI haha

Gl in your project !
 
Agreed. I'm looking a bit in the exe to see if I can decipher where they mash together the csv info from. I'm not very good at reading assembly, but I'll let you know if I find something.

My assumption is the DB table is created at runtime. The csv files and values are very similar to the DB values in the AI tables, and the other information turn, playedID, etc are the same types of values as stored in the DB. This leads me to believe that we'll be able to find them if we know the table names.

Yeah it would make sense that some of the data is at least out there, if perhaps not stored per turn number, but at least kept around in some temporary storage. If you find anything let me know, if that info could be placed directly on screen it'd be way easier to know what the AI is doing.



Well, i don't know what to choose beetween this one and Delnar AI haha

Gl in your project !

Thanks! I haven't personally tried his mod yet so I can't really give a recommendation for either one. Both are slightly overlapping, with each of us coming up with different answers to the some problems and both deal with issues the other hasn't tried for yet. Feedback is welcome about which mod does what aspect best. As for now I definitely don't recommend using them together, some stuff will probably blow up haha. Might have to discuss with him whether we can find some solution there.
 
I have all the AI logs.... do you guys not? It's a setting in the configs if I remember right.
 
Ya, I've got these. I would LOVE to know where they are in the in-mem LUA tables.


Via the Lua console in FireTuner (from the Civ 5 SDK) this is all that is listed in GameInfo.


I.E. It doesn't seem like the GameInfo changes during runtime (even in memory). At least, the AI_ versions of Victories/Espionage/CityBuild etc are not stored there.

I'm looking for the corresponding lua table (like GameInfo) which has the current state of the AI.
 
The AI fought really well with this mod, ranged and melee were a pleasure to fight!

That's great to hear! I'm a little surprised to be honest, because I've only attempted small changes in that particular area in v1. But hey can't be sad about that result!
Do let me know if it ended up just being a fluke or something, it would help me figure out how much control we really have there.
 
Some suggestions:
  • Right now it seems as if the AI uses it‘s own units isolated from any context. Therefore you will see an isolated Catapult crawling around the war zone, an easy target to pick for any opponent. Instead the AI should combine units and use micro tactics. E. g. if the player‘s forces mainly consist of Horsemen, the AI could combine a Spearman and an Archer, use the Spearman to defend against Horsemen attacks, and use the Archer to weaken the attackers while staying behind their own Spearman in the second row.
  • It seems like the AI has no good sense of the relative strength or value of any given unit. From my perspective it seems like the AI doesn‘t bother to update units, as long as it has more units than anybody else. 3 Warriors are better than 2 Swordmen, because more is always better, right? No. It would be better if the AI sold one of the Warriors and upgraded the two remaining Warriors to Swordmen. I think you get my point. I have seen a lot of instances where the AI had already progressed into Renaissance era, but it's army still consisted of crappy Spearmen and Warriors.
  • Also the balance of AI armies seems way off. City states seem to be very fond of Catapults, so you see 50 % or more of their army consisting of Catapults, the rest are Warriors. But why build Siege Units if you don‘t plan to take a foreign City? (Btw, can City states conquer other cities? ;-) So what‘s the point?) Also you don‘t need more than like two Catapults for a single campaign. Maybe a third as a replacement. Just an idea.
  • Declarations of war are a real problem. It seems as if the AI players don‘t have an idea of what to achieve with a war. But you don‘t fight a war if you don‘t have a goal. And even if you have a goal, you need to be pretty confident, that you actually can achieve it. I‘ve seen a lot of very dumb DOWs. They declare war, they move units into your territory, and then? Nothing happens. They move around, they don‘t attack anything, they don‘t even pillage in order to heal. Only thing they are doing is to die. That‘s stupid. AI players should have a basic plan and an idea of how to achieve a defined goal. And there has to be an assessment at the end of each round, if the goal can still be reached, and if not, if it can be modified. If there is no chance, the AI should try to settle the conflict, maybe even pay reparations (peace deal, favorably for the player). But the peace deal should also not be hilarious, like it is right now. I‘ve seen instances where AI declared a war on me, then lost it‘s whole army, I hadn‘t even started to push back into their territory, and the AI asked for peace by offering me several cities, all their gold and luxuries. That‘s quite strange.
  • AI players should have a rough idea of the value of the resources they are offering in a deal. There should be a minimum value. If I don‘t offer the minimum, they won‘t accept the deal. Also they should remember the value they assigned to something. Right now I can ask for Open Borders, they aks for 15 GPT in return, I offer 7, they decline, I ask for what they want instead, they say 1 GPT plus 30 Gold fixed, which is 2 GPT. LOL
 
Some suggestions:

Thanks for these!
Unfortunately most of what you mention is right now out of reach for us modders without access to the code.
As far as I can tell so far, the upgrading units problem happens most commonly when the AI doesn't have any iron or gold and just can't upgrade them. What it really should be doing of course is to disband some of its units, and replace them with more modern units that it can build. I've seen a possible avenue for making this possible, but even if that works it's probably going to be rather rudimentary, because you don't really want to risk the AI disbanding all of its units pointlessly.
Haven't seen a city state conquer a city yet, and I think there's some limitations in place that would at least make that very unlikely. So yeah the catapults is rather idiotic (although to be far, their ranged attack is pretty decent). I think there's a way to at least stop city states from doing that. Overall improvements to army balance are going to be prtty hard though, we have little control over what units will actually be build. It seems to calculate by itself, based on combat strength etc which it will build.
Hopefully the 'moving units into your territory and then stopping' issue will be gone in v2 of this mod, I'm currently in the process of testing some changes here.
Unfortunately I Haven't seen any way to change the diplomacy system to make them a little smarter there. They do like giving their cities up way too much.
 
So someone said in one of his posts that the AI civs spam warriors and slingers (for one reason), in that they don't cost maintanence, so I've put the warrior and slinger maintanince to one, and honestly, with the civs (Not city states), I haven't seen the screen full of troops since. But yeah, they AI is still horrible at upgrading them, either because they don't have the tech (Which is unlikely as I was China (Not doing the best) and finally got to machinery, and Japan still had slingers and warriors.

Also will you be touching on how terrible the diplomacy is?? I had one trade where they wanted a luxry from me, and were offering me some money, some GPT and something else, so I thought I would be a fully sick neighbor and modify the deal to add something else from me, and then they turned around and were wanting GPT a strategic resource and a luxury resource for nothing!!

Also another game I'm on (I have lowered the war mongering penalties), although twice now I've had two civs declare a formal war on me in the second ear, when I hadn't done anything to trigger them AND one of them was like +14 on our relationship scale?!! I had a like -4 against a +18!

Anyway, sorry I got carried away on that little rant!
 
Top Bottom