Resource icon

AI+ v13.1

And Siesta Guru, can you check your mod (AI+) to make sure the AI players are using Bombers, Jet Bombers, Fighters and Jet Fighters correctly (I see them building them but not using them for anything). Right now the default fall patch AI is using them (not that good but is using them).

Will test this, thanks for letting me know.

I am sorry to keep asking for help but where in the “BehaviorTrees.xml” and “Operations.xml” files or just wherever files would I go to fix the AI players units getting stuck around a city and late game wars not getting launched by the AI players? I have really looked and just do not know what I need to change.

So these fixes are already in AI+. But if you want to mimic them, you need to:


For the 'stuck around cities fix'
You can just rip the code in behaviortrees.xml out of AI+, but you'll get some other small changes along with it. So if you don't want that, here's a bit of an explanation that hopefully helps you figure out how the behaviortrees works

Find the <BehaviorTreeNodes> corresponding to : NodeType="Operation Move" for the relevant behaviortree. In particular, the one node thats relevant for city attacks is:

<Row NodeType="Operation Move" NodeId="39" TreeName="Siege City Assault" />

As its executed right before the bulk of the actual attacking logic
Then find the <TreeData> corresponding to the nodes you want to change. Which should be:
<Row DefnId="0" NodeId="39" TreeName="Siege City Assault" DefaultData="1" />
<Row DefnId="1" NodeId="39" TreeName="Siege City Assault" DefaultData="2" />
<Row DefnId="2" NodeId="39" TreeName="Siege City Assault" DefaultData="false" />
<Row DefnId="3" NodeId="39" TreeName="Siege City Assault" DefaultData="2" />

In the NodeDataDefinitions we can see what these mean:
<Row DataName="Move To (enum)" DefnId="0" DataType="int" NodeType="Operation Move" Required="False" UserData="True" />
<Row DataName="Range to goal" DefnId="1" DataType="int" NodeType="Operation Move" UserData="True" />
<Row DataName="Validate new units" DefnId="2" DataType="bool" NodeType="Operation Move" Required="False" UserData="True" />
<Row DataName="Unit distance" DefnId="3" DataType="int" NodeType="Operation Move" Required="False" UserData="True" />
<Row DataName="Leader Tag" DefnId="4" DataType="string" NodeType="Operation Move" Required="False" UserData="True" />

The node with id 3 (Unit Distance) is the one that determines the distance within which units need to be. As we can see it's currently set to 2. So all you need to do is change it to 3.

So turn
<Row DefnId="3" NodeId="39" TreeName="Siege City Assault" DefaultData="2" />
into
<Row DefnId="3" NodeId="39" TreeName="Siege City Assault" DefaultData="3" />
You can do this either by updating it, or by deleting it and creating a new one or by using sql. I like doing the latter on the entire tree in AI+ because it minimizes the risk that a civ patch causes everything to crash (if ids ends up changing, an update would override data of the wrong node). Its also pretty easy in case of behaviortrees. Just delete all nodedata and all behaviortreenodes inside some tree, then copy paste the original tree in while altering what you want.


For the 'operationtypes' fix, note that these operations:
<Row OperationName="City Defense" TargetType="TARGET_FRIENDLY_CITY" TargetParameter="1" BehaviorTree="Simple City Defense" Priority="4" MaxTargetDistInRegion="-1" MaxTargetDistInArea="-1" MaxTargetDistInWorld="0" />
<Row OperationName="Civilian Builder Capture" TargetType="TARGET_FRIENDLY_CITY" BehaviorTree="Escort Worker To Camp" Priority="1" MaxTargetDistInRegion="-1" MaxTargetDistInArea="-1" MaxTargetDistInWorld="0" />

Don't have an OperationType set, while all other (non-barb) operations do have something set there.
Strangely enough, the xml does provide two defined operationtypes which were supposedly intended for these two:
<Row OperationType="OP_ESCORT" Value="2" />
<Row OperationType="OP_DEFENSE" Value="4" />

So just set the operationtypes to these. You can do this through a delete + new create or an update or by using sql
In AI+ I'm using an update here. Basically just add these lines to your mod inside of an AiOperationDefs xml block:

<Update>
<Set OperationType="OP_ESCORT"></Set>
<Where OperationName="Civilian Builder Capture"></Where>
</Update>
<Update>
<Set OperationType="OP_DEFENSE"></Set>
<Where OperationName="City Defense"></Where>
</Update>
 
Will test this, thanks for letting me know.



So these fixes are already in AI+. But if you want to mimic them, you need to:


For the 'stuck around cities fix'
You can just rip the code in behaviortrees.xml out of AI+, but you'll get some other small changes along with it. So if you don't want that, here's a bit of an explanation that hopefully helps you figure out how the behaviortrees works

Find the <BehaviorTreeNodes> corresponding to : NodeType="Operation Move" for the relevant behaviortree. In particular, the one node thats relevant for city attacks is:

<Row NodeType="Operation Move" NodeId="39" TreeName="Siege City Assault" />

As its executed right before the bulk of the actual attacking logic
Then find the <TreeData> corresponding to the nodes you want to change. Which should be:
<Row DefnId="0" NodeId="39" TreeName="Siege City Assault" DefaultData="1" />
<Row DefnId="1" NodeId="39" TreeName="Siege City Assault" DefaultData="2" />
<Row DefnId="2" NodeId="39" TreeName="Siege City Assault" DefaultData="false" />
<Row DefnId="3" NodeId="39" TreeName="Siege City Assault" DefaultData="2" />

In the NodeDataDefinitions we can see what these mean:
<Row DataName="Move To (enum)" DefnId="0" DataType="int" NodeType="Operation Move" Required="False" UserData="True" />
<Row DataName="Range to goal" DefnId="1" DataType="int" NodeType="Operation Move" UserData="True" />
<Row DataName="Validate new units" DefnId="2" DataType="bool" NodeType="Operation Move" Required="False" UserData="True" />
<Row DataName="Unit distance" DefnId="3" DataType="int" NodeType="Operation Move" Required="False" UserData="True" />
<Row DataName="Leader Tag" DefnId="4" DataType="string" NodeType="Operation Move" Required="False" UserData="True" />

The node with id 3 (Unit Distance) is the one that determines the distance within which units need to be. As we can see it's currently set to 2. So all you need to do is change it to 3.

So turn
<Row DefnId="3" NodeId="39" TreeName="Siege City Assault" DefaultData="2" />
into
<Row DefnId="3" NodeId="39" TreeName="Siege City Assault" DefaultData="3" />
You can do this either by updating it, or by deleting it and creating a new one or by using sql. I like doing the latter on the entire tree in AI+ because it minimizes the risk that a civ patch causes everything to crash (if ids ends up changing, an update would override data of the wrong node). Its also pretty easy in case of behaviortrees. Just delete all nodedata and all behaviortreenodes inside some tree, then copy paste the original tree in while altering what you want.


For the 'operationtypes' fix, note that these operations:
<Row OperationName="City Defense" TargetType="TARGET_FRIENDLY_CITY" TargetParameter="1" BehaviorTree="Simple City Defense" Priority="4" MaxTargetDistInRegion="-1" MaxTargetDistInArea="-1" MaxTargetDistInWorld="0" />
<Row OperationName="Civilian Builder Capture" TargetType="TARGET_FRIENDLY_CITY" BehaviorTree="Escort Worker To Camp" Priority="1" MaxTargetDistInRegion="-1" MaxTargetDistInArea="-1" MaxTargetDistInWorld="0" />

Don't have an OperationType set, while all other (non-barb) operations do have something set there.
Strangely enough, the xml does provide two defined operationtypes which were supposedly intended for these two:
<Row OperationType="OP_ESCORT" Value="2" />
<Row OperationType="OP_DEFENSE" Value="4" />

So just set the operationtypes to these. You can do this through a delete + new create or an update or by using sql
In AI+ I'm using an update here. Basically just add these lines to your mod inside of an AiOperationDefs xml block:

<Update>
<Set OperationType="OP_ESCORT"></Set>
<Where OperationName="Civilian Builder Capture"></Where>
</Update>
<Update>
<Set OperationType="OP_DEFENSE"></Set>
<Where OperationName="City Defense"></Where>
</Update>

:( I am still having issues... I have never used sql (I tried I just do not know how to work it and I did see a YouTube video or two so I will watch them later and try doing a sql again) and I am not sure how you do a "delete + new create" and I tried to insert "<Update>" using your mod (after deleting everything in your mod so I could use it as a template) but still did not work. Lastly, I want to the "BehaviorTrees.XML" in Base\Assets\Gameplay\Data and changed
<Row DefnId="3" NodeId="39" TreeName="Siege City Assault" DefaultData="2" />
into
<Row DefnId="3" NodeId="39" TreeName="Siege City Assault" DefaultData="3" /> but after that the AI player just started moving their units back and forth not even going near my city (so, that just made it worse). I had a backup and have undone that change. I did each of these attempts separately too. Yeah, modding is not easy and I really do appreciate your help and I hope I can still get this.
 
So for an example of delete + a new create, see the behaviortrees.xml file in AI+.
I do a delete on all <TreeData> of the tree Siege City assault using: <Delete TreeName="Siege City Assault"/>
Then I recreate the same tree by just defining new tredata elements. There's a lot of them in there, and that's because it's mostly just a duplicate of the original behaviortrees with some changes
You do need to be inside of a mod to do this.

Your way -changing the base files- also works though, and in theory your change should've been the correct one. The fact that the behavior seems worse probably doesn't mean that much. It's a very chaotic/random game, so small positive changes don't necessarily mean that the end result will be better in every single game.
Changes to the mods used etc on an already saved game are not handled very well, and it's recommended to start with a clean game after mod changes.
 
At Siesta Guru: So, I want back to the "BehaviorTrees.XML" in Base\Assets\Gameplay\Data and changed <Row DefnId="3" NodeId="39" TreeName="Siege City Assault" DefaultData="2" />

into

<Row DefnId="3" NodeId="39" TreeName="Siege City Assault" DefaultData="4" /> and the AI player is at least attacking and taking all my cities but it is taking them forever to do that as they still waste a lot of time just moving back and forth with their units. This is an improvement to what was happened before, in games with no modifications/mods to the AI player who would sometimes never take any cities doing the late game (note I have only done 2 test games and will do some more to make sure the changes I made are really making a difference).





So, how do I do modifications to the Base\Assets\Gameplay\Data files to add

<Update>
<Set OperationType="OP_ESCORT"></Set>
<Where OperationName="Civilian Builder Capture"></Where>
</Update>
<Update>
<Set OperationType="OP_DEFENSE"></Set>
<Where OperationName="City Defense"></Where>
</Update>

the fix for the “operationtypes” as me and making mods is not really working out, please? Like, in what lines should I paste and/or change and so on?
 
Last edited:
Turn these two lines in operations.xml:
<Row OperationName="Civilian Builder Capture" TargetType="TARGET_FRIENDLY_CITY" BehaviorTree="Escort Worker To Camp" Priority="1" MaxTargetDistInRegion="-1" MaxTargetDistInArea="-1" MaxTargetDistInWorld="0" />
<Row OperationName="City Defense" TargetType="TARGET_FRIENDLY_CITY" TargetParameter="1" BehaviorTree="Simple City Defense" Priority="4" MaxTargetDistInRegion="-1" MaxTargetDistInArea="-1" MaxTargetDistInWorld="0" />
Into:
<Row OperationName="Civilian Builder Capture" OperationType="OP_ESCORT" TargetType="TARGET_FRIENDLY_CITY" BehaviorTree="Escort Worker To Camp" Priority="1" MaxTargetDistInRegion="-1" MaxTargetDistInArea="-1" MaxTargetDistInWorld="0" />
<Row OperationName="City Defense" OperationType="OP_DEFENSE" TargetType="TARGET_FRIENDLY_CITY" TargetParameter="1" BehaviorTree="Simple City Defense" Priority="4" MaxTargetDistInRegion="-1" MaxTargetDistInArea="-1" MaxTargetDistInWorld="0" />


Btw from testing I'm pretty sure DefaultData="3" is better than DefaultData="4". 4 looses it up so much that armies become way too spread out.


So I've noticed that this file is still in the mod, probably best to remove it at the next update.

Ah yes, thanks for reminding me, I deleted it now in my local version. So it should be gone next patch.
 
Turn these two lines in operations.xml:
<Row OperationName="Civilian Builder Capture" TargetType="TARGET_FRIENDLY_CITY" BehaviorTree="Escort Worker To Camp" Priority="1" MaxTargetDistInRegion="-1" MaxTargetDistInArea="-1" MaxTargetDistInWorld="0" />
<Row OperationName="City Defense" TargetType="TARGET_FRIENDLY_CITY" TargetParameter="1" BehaviorTree="Simple City Defense" Priority="4" MaxTargetDistInRegion="-1" MaxTargetDistInArea="-1" MaxTargetDistInWorld="0" />
Into:
<Row OperationName="Civilian Builder Capture" OperationType="OP_ESCORT" TargetType="TARGET_FRIENDLY_CITY" BehaviorTree="Escort Worker To Camp" Priority="1" MaxTargetDistInRegion="-1" MaxTargetDistInArea="-1" MaxTargetDistInWorld="0" />
<Row OperationName="City Defense" OperationType="OP_DEFENSE" TargetType="TARGET_FRIENDLY_CITY" TargetParameter="1" BehaviorTree="Simple City Defense" Priority="4" MaxTargetDistInRegion="-1" MaxTargetDistInArea="-1" MaxTargetDistInWorld="0" />


Btw from testing I'm pretty sure DefaultData="3" is better than DefaultData="4". 4 looses it up so much that armies become way too spread out.




Ah yes, thanks for reminding me, I deleted it now in my local version. So it should be gone next patch.


... next patch you say!?
 
Thank you Siesta Guru! That seems to have fixed it making those changes; the AI players are more aggressive with taking cities doing the late game. Just need to run a few more test games.



I am still keeping <Row DefnId="3" NodeId="39" TreeName="Siege City Assault" DefaultData="2" /> at set DefaultData="4" because when I have it at 3 the AI players seem to act weird and not attack my cities or any cities… what settings are you using when you run your test with it set to DefaultData="3" maybe I have to many changes made to the Base\Assets\Gameplay\Data and/or mods and that is why “3” seems to not work for me? And the only changes to the Base\Assets\Gameplay\Data are the fixes for the stuck around a city and AI not being aggressive late game.
 
Something, else I saw doing some of my test games on giant map sizes (most of my test games have been on small or duel size maps too), the AI players would not attack me a lot if I was on one side of the map and them on the other side. I was the only person they were at war with but still they did not generally launch any attacks (send units to try and take my cites), anyway to make the AI players more willing launch attacks against someone they are at war with on the other side of the map (like on giant maps), especially if the target is about to win one of the victory conditions?
 
Last edited:
Plus, when the AI players starts using nukes they tend to move their units towards the city that got nuked and stop… anyhow their units keep dying in the radiation and they never take the city (they keeping nuking the same city until they capture it, at least in my games). Anyway, to force the AI player to just sacrifice a unit that has enough movement to get to and take a city in radiation so at least they hopefully stop killing all their own units trying to surround a city in radiation (they keep nuking)?
 
Last edited:
Hey Siesta, when are you looking at updating "AI+" again? Also did you ever check to make the AI players are using air units correctly are at least using them for something in the "AI+" mod? Lastly, is the "AI+" mod compatible with the "Warfare Expanded (for MOAR)" like will the AI players build the new air units (like the "Great War Bomber" and others) in that mod and use them?
 
Hey guys, tiny question - is this AI improvement compatible with October updates (Khmer and Indonesia)?
 
Hello everyone!
I have often noticed that you can rush some AI cities in the early game if you build 4-5 galleys, which is easy with the right policy card (even on Demi-God). So I would like to see that the AI uses at least 1 or 2 naval units to protect their coastal cities. Maybe by increasing the MaxNumber of naval units for city defense operations?

Another thing I have noticed is that in the vanilla file of Leaders.xml there are some entries with "YEILD_PRODUCTION". It is probably misspelled by Firaxis, but I could not find any fix in AI+. So maybe it could prevent some bugs if you corrected this typo in your mod?

Regarding city states I would suggest to put encampments and walls in their favored list items, if this is possible. Their most important task should be surviving instead of building civilian districts (I am not even sure if campuses, holy sites or theaters help them at all, if city states follow other game rules than major civs).

By the way I have started to create a balancing mod myself to improve the AI a few months ago. In a few weeks I should be uploading it on steam. One of my ideas is to nerf ranged units, because the AI does not handle them as well as human players.
Especially siege units should be nerfed in my opinion, but I do not know how well the AI uses ranged siege units in your games. In my games with AI+ the AI builds almost no siege units, so I am not sure if it is only me. Only once I have seen a bombard attacking a city state, but then it retreated again.
 
First, let me say that I know the Civ6 AI is incompetent. I commend the OP for trying to solve this problem with limited access to resources.

I used the AI+ mod in an AI battle royale. 8 civs. After 11 hours and 2100 turns, the year is 2847 AD. And no one is fighting.

I've forced each Civ to declare war on each other. Yet after a few turns, they all make peace with each other.

Rome has the most territory and cities, yet refuses to destroy the smaller, weaker civs around it.

Was Civ6 made by SJWs or hippies because the game sure feels like it.

Looks like I'll be headed back to Civ5 Vox Populi.
 
in my last games with ai+, I often see the AI not moving is huge armies and fleet, or not attacking my close-by units, even when in range of shoot :/
in the Unit_operations Log, there is a lot of "can't start" lines , most often with the move_to commands
(last game, 4k "cant start" lines, on 28k lines, so thats minimum 15% of the ai commands that don't succeed)

If I had to try a wild guess, I would say that the AI gives a move_to command, and if you block his unit, he won't change the order and the unit will stay stucked until the situation change.
It would be good if the AI would be able to change those orders, attacking the units that block him when possible.

It appears quite often too that the range units into fortification wont' shoot at you.
Let me know if you're inerested in my logs.

Cheers, and thank you for your work
 
is this AI as/more stable than the vanilla one? having fewer cons is more important than more pros for me.
 
I believe it's still better than Firaxis AI (it also doesn't always negate AI changes in the base game), but if you're not certain you can also go for Civ Flavour Deity, which I have found to do WONDERS for the AI.

@Siesta Guru Will you update this mod for the expansion or will you not buy the expansion?
 
Back
Top Bottom