1. We have added the ability to collapse/expand forum categories and widgets on forum home.
    Dismiss Notice
  2. All Civ avatars are brought back and available for selection in the Avatar Gallery! There are 945 avatars total.
    Dismiss Notice
  3. To make the site more secure, we have installed SSL certificates and enabled HTTPS for both the main site and forums.
    Dismiss Notice
  4. Civ6 is released! Order now! (Amazon US | Amazon UK | Amazon CA | Amazon DE | Amazon FR)
    Dismiss Notice
  5. Dismiss Notice
  6. Forum account upgrades are available for ad-free browsing.
    Dismiss Notice

AI+ v12.1

AI Improvements for Civ VI

  1. Lion King

    Lion King Chieftain

    Joined:
    May 24, 2015
    Messages:
    56
    Gender:
    Male
    Location:
    Russia / UK
    Thanks for looking on this! I tried not to touch anything apart from Naval groups and just new operations but will definitely amend operations and behaviortree. Regarding behavior tree issue - how did you spot this in the game? I saw so many times AI not doing anything because of this issue and was always wondering whether they are trying to hire more units.

    I am now focusing on adding proper naval city attacks, AI is relatively okay with doing land combats in AI+ (even in base game it became better). I believe Siesta is waiting for a better modding tools but we can always try to ask him for an update...)

    Yeah, same thing, I never saw AI using them. I believe AI just consider them "inefficient" because they cost a lot but cannot attack units or cities.
    AI definitely can be made building them, there are several potential ways of doing it:

    1. Simple way (not sure if it works): by adding it to AiFavoredItems and also checking that carrier unit belongs to Unit_Naval class.
    2. More complicated: Creating separate class for these units (unit_naval_carrier), creating new team (Naval Base strike team) with minimum number of unit_naval_carrier at least one, creating new operation linked to this team (Naval base strike operation) with ideally its own operation type. Then you can give this operation type allowed limit and put it in favored items with the precondition of player reaching tech which allows building of carriers. There is a "ZergRush" type of operation done in AI+, you can create carrier operation using this as a template.
    AI should build carriers and use them as part of naval formation (if you put siege city assault as behavior tree) however I believe it won't be putting airplanes into carriers and using them - this is where the whole behavior tree needs to be created. Siesta can better advise on this.
     
  2. Siesta Guru

    Siesta Guru Chieftain

    Joined:
    Dec 2, 2007
    Messages:
    487
    Location:
    The Netherlands
    Yeah I'm just doing maintenance now really. Without better tools I don't feel I can add much more, inspiration for truly fundamental changes has run out so it's mostly just doing weight tweaks now. And while doing that can improve AI skills, it's too difficult to say to what extend they truly help the AI, especially since there's no way of having different players use different weights.

    Do you mean the issue where they get stuck around a city? Or the operations not being launched thing?
    I noticed the 'stuck around city' thing by looking at the operation and behaviortree logs when I saw a particularly awful case where Scythia surrounded a city near mountains for hundreds of years and never attacked. It turned out they just got stuck in a movement node. I saw movement nodes has a variable for the minimum distance required, and saw that there were simply too many too units to be able to fit them all within a 2 tile radius (like 15 units for 7 tiles) so it could never get them all in range. Turns out there are actually 2 variables for distance. As far as I understand it now, there's basically a sort of 'center' (or leader?) of the operation. To complete a movement node, the center of the operation must be within a certain tile radius of the target goal, and all units must be within a tile radius of the center. Especially the latter is impactful.

    Operations not being launched took me much longer and was one of the last genuinely impactful changes I did. For a while I had noticed that in late game, civs would build very few units. Later on I noticed in the logs that city attack operations would frequently just not start whatsoever, even if the civ in question has a sizeable army through upgrading medieval units. If operations don't even start, they never get to the recruiting phase, nor to the building contracts, which is their prime way of building military units. So the operations not starting seemed like the key, but I couldn't find a solution. For the longest time I thought it was that they simply felt too weak to attack cities lategame, possibly because of the large walls. Eventually though it became obvious that no matter what tweaks I did to minoddsofsucces, to min troop requirements, to unit combat strengths; the issue wouldn't disappear. Civs would also miss possible attacks on incredibly weak backwards civs.
    After lots of looking through logs, I noticed one civ in particular that had 2 'return civilian' operations running, which for some reason didn't end for hundreds of turns. During the entire time, not a single city attack operation was launched. The pattern showed up in more games, so I had a look if there was anything special about the return civilian operation, and there was, no opeartiontype was set. The same ended up being true for the city defense operation, which was also frequently present in lategame. Adding proper operationtypes to both of them basically instantly did the trick and civs became way more active late.


    Count me in as never having seen them make use out of carriers the proper way. Sometimes they build them, but use them only as melee ships. Any support units in general are generally either never build or nor handled well. Sometimes a battering ram or one of those scout balloons is carried along, but I've yet to see a great general, admiral or medic being used. And I've watched a lot of games...
     
    notque and Olleus like this.
  3. Bate1999

    Bate1999 Chieftain

    Joined:
    Dec 22, 2010
    Messages:
    60
    At Siesta Guru and Lion King, anyway you two can combined your mods as I run a game using both on a duel map, set to immortal, starting in the Renaissance era and the AI player was able to take my city within like 15 to 20 turns (I was not really trying to hold them off to much for this test run) that was much faster than I have ever seen from the AI players (as they usually dance their units around my city), they also had a few ships that also attacked. The problem is when I run both of your mods the game becomes really unstable and starts to crash randomly a lot, so yeah I am hoping you two could make a more stable mod.
     
  4. Bate1999

    Bate1999 Chieftain

    Joined:
    Dec 22, 2010
    Messages:
    60
    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).
     
  5. Bate1999

    Bate1999 Chieftain

    Joined:
    Dec 22, 2010
    Messages:
    60
    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.
     
  6. Leyrann

    Leyrann Warlord

    Joined:
    Jan 11, 2015
    Messages:
    3,375
    Gender:
    Male
    Location:
    Netherlands
    I'm pretty sure Siesta is at a loss regarding this as well...
     
  7. Bate1999

    Bate1999 Chieftain

    Joined:
    Dec 22, 2010
    Messages:
    60
    I wish I knew more about the "operationtypes" I just keep poking at it. Also, are there any self help guides for Civ 6 AI modding yet?
     
  8. Siesta Guru

    Siesta Guru Chieftain

    Joined:
    Dec 2, 2007
    Messages:
    487
    Location:
    The Netherlands
    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>
     
  9. Bate1999

    Bate1999 Chieftain

    Joined:
    Dec 22, 2010
    Messages:
    60
    :( 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.
     
  10. Siesta Guru

    Siesta Guru Chieftain

    Joined:
    Dec 2, 2007
    Messages:
    487
    Location:
    The Netherlands
    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.
     
  11. Olleus

    Olleus Warlord

    Joined:
    Oct 30, 2005
    Messages:
    6,430
    Location:
    England
    So I've noticed that this file is still in the mod, probably best to remove it at the next update.
     
  12. Bate1999

    Bate1999 Chieftain

    Joined:
    Dec 22, 2010
    Messages:
    60
    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: Nov 5, 2017
  13. Siesta Guru

    Siesta Guru Chieftain

    Joined:
    Dec 2, 2007
    Messages:
    487
    Location:
    The Netherlands
    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.
     
    Olleus likes this.
  14. Smity2k1

    Smity2k1 Chieftain

    Joined:
    Jan 10, 2015
    Messages:
    118

    ... next patch you say!?
     
  15. Bate1999

    Bate1999 Chieftain

    Joined:
    Dec 22, 2010
    Messages:
    60
    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.
     
  16. Bate1999

    Bate1999 Chieftain

    Joined:
    Dec 22, 2010
    Messages:
    60
    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: Nov 7, 2017
  17. Bate1999

    Bate1999 Chieftain

    Joined:
    Dec 22, 2010
    Messages:
    60
    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: Nov 8, 2017
  18. Bate1999

    Bate1999 Chieftain

    Joined:
    Dec 22, 2010
    Messages:
    60
    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?
     
  19. Sting

    Sting Chieftain

    Joined:
    Jun 26, 2011
    Messages:
    68
    Location:
    Russia
    Hey guys, tiny question - is this AI improvement compatible with October updates (Khmer and Indonesia)?
     
  20. ggalindo001

    ggalindo001 Chieftain

    Joined:
    Jan 4, 2002
    Messages:
    207
    Yes. However, I do believe Siesta is going to do a further update.
     

Share This Page