Resource icon

AI+ v13.1

Quick update on my Smoother king difficulty tiny continents game with v1.11

in 1926

it is me and 2 AIs left:
Trajan is the competent AI with 7 cities, he is waging a long war against Gilgamesh and is winning that, Sumer has now only 2 cities left...

I have cleared Gorgo and Monty on my continent, and then Scythia on a big island - have about a dozen+ cities...

I have just reached Atomic age, both Trajan and I have 75 techs and about 300/turn sci at this moment

EDIT

1958, only Trajan and me left - and Rome declared war on me with 4k military, while I have 2k...

Rome also turned to Fascism in the turn he attacked me...
He has no navy but lots of land units - will he try land units in group on my continent?
I have navy, so I can defend in the first wave...

EDIT 2

I won against Trajan by domination in 2014.

Trajan made 2/3 of science victory, which was quite nice.
He failed to make air and naval force - that made him lose easily against my forces of bombers and combined naval forces...
 
Last edited:
So I'm back to CIV 6 for the first time after the summer patch, and AI+ isn't working. :sad:

When I try to create a new game, it just says 'start game' briefly and then returns to the main screen. I've reinstalled the game and disabled all other mods, and I still get this error. I've uploaded my log files here.

As far as I can see, database.log is complaining that some unit types don't exist.
 
@Siesta Guru
If it's not too much trouble, could you explain how the AI's behavior trees are organized? I looked in base game files and can't make heads or tails of anything
 
I have tried this twice now & come up mixed results. Firstly, I enjoy that the AI is far more competitive; however, the settling behavior is way out of common sense. I am on the Play Europe Again TSL map (Deity), and Poland (for example) settled right next to Paris. This is well over 30 away. All of the other Civs are also doing this stupid stuff of settling 20 to 30+ hexes away; and ignoring good land right next them. In the above, obivously Poland saw something great in the hexes 4 to 6 away from Paris, but France was busy settling Prague, below Berlin. To me, this kills it completely for the AI trying to act better.
 
I have tried this twice now & come up mixed results. Firstly, I enjoy that the AI is far more competitive; however, the settling behavior is way out of common sense. I am on the Play Europe Again TSL map (Deity), and Poland (for example) settled right next to Paris. This is well over 30 away. All of the other Civs are also doing this stupid stuff of settling 20 to 30+ hexes away; and ignoring good land right next them. In the above, obivously Poland saw something great in the hexes 4 to 6 away from Paris, but France was busy settling Prague, below Berlin. To me, this kills it completely for the AI trying to act better.

This isn't only the mod though, it's also present in the base game.
 
Thanks Leyrann, good to know it also base game. I will add in to this that without AI+ the AI settles much closer to its other cities, i.e. 3 to 8 hexes, from what I have seen.
 
My first time trying out the mod. I used it with 8 ages of pace/war and CQUI.

Honestly, In my king game the AI was extremely passive. I was the lowest in military the entire game and dominating the AI in science, yet was never attacked. I even attacked a CS just to try and piss off the AI, got several denounces but still no declares.
 
Hey guys,
I am trying to alter the mod to make AI using ships and airplanes more often. Re ships - I think of two ways: either special operation needs to be creates e.g. "Naval Assault" where you can put minimum number of ships and force AI to use them. However, I am not familiar with operations node writing so I can very easily mess the whole thing.
Or alternatively I can put max number of ships as non-zero value in current operations and this should also make AI to use them sometimes. However this might change other land operations impacting them in a negative way.
 
One thing I've noticed with the AI settling is that they often have a settler out but sometimes it takes them a very long time to actually put down a city. It's like they're searching for the perfect spot or something. It can sometimes leads to their cities not being very tighly clustered since they settle all over the map (depending on where the "best" tiles are, usually the ones with the most resources) which makes it easier to pick off their cities one at a time. Is there any way to get the AI to care less about finding that perfect tile and settle closer to their empire. By having a settler roaming for so many turns the AI is missing out on a lot of valuable time that could be spent building that city up and building another settler.
 
So what's up with behavior trees?
As far as I can tell, they're linear ... not very tree-like. Because I'm seeing no way that they actually distinguish branches
Example: The barb action tree. It seems like a linear series of actions.
Like once the found city tree is activated, the attack city tree loops infinitely (which is expected behavior), but there are no branches anywhere.
I'll be analyzing other trees to see if that's the case for everything
 
@DemonEmperor

The behaviortrees are very simplistic and don't really offer a lot of options. They're indeed essentially linear. The most you can really get out of them is structures like:

state = 1;
if state == 1{
dostuff();
state = 2;
}
if state == 2{
dootherstuff();
}
Honestly I wouldn't bother trying on them too much. Besides not having much of control over flow, the conditionals are extremely limited and the actions basically consist of a few pre determined options only a few ever make sense in their context. They're also combined together using variables held invisibly somewhere in the c++ code that you cant really access. As a cherry on the cake, mistakes here often crash the client, and even if they don't, usually don't really give you any useful info.
Structure wise, you basically have 3 types of xml tags.
1. Definitions /datatypes. You cant do anything with these. It just helps you to see what can be done
2. BehaviorTreeNodes. The meat of the behaviortrees. These form the 'tree' structures and indicate what type of node were dealing with.
3. TreeData. Variables belonging to the nodes. The combination of NodeId and TreeName points to a unique node among the BehaviorTreeNodes. The DefnId shows you what type of variable it describes. Look up what nodetype its refering to in BehaviorTreeNodes, then combine that with the DefnId here. That points to a unique value in the NodeDataDefinitions that will tell you what kind of variable it is. If NodeDataDefinitions mentions a DefnId that isnt used in the TreeData, then you can add it yourself if you want to.

The Jumptos in BehaviorTreeNodes organize the flow somewhat. A node with a jumpto is basically like a set of brackets, starting with the node youre in, ending right before the mentioned node, or if you want, they form a branch. Use a jumpto with the first nodeid no longer in the tree to exit the tree, the operation that this tree was running on will end when you do that. Since the jumptos basically indicate branches/brackets rather than gotos you cant actually jump back to earlier nodes nor can you switch to other branches. Using Concurrent, Priority and Sequence nodes you can create a sort of structure of if statements. "Sort of" because as far as I remember (it's been a while) it's impossible to do proper "else" and "elseif" blocks. I gave up trying anyway

Some node types basically halt execution of the tree until some condition is met. For example, a move to node will not complete until the units have reached their goal. Others basically pass instantly, sometimes unexpectedly. The make formation node for example always passes instantly. If units cant make formations the turn that node is acitvated, the tree will keep going on

If you want more detailed info on any of the nodes in particular I could try and give you some pointers. All my knowledge is experimental/inferred though, so in some cases I don't know what exactly is going on either
 
So I've done some digging: the file delnars_fixes.xml is superfluous. All the changes inside of it have been added to the Vanilla game, the file doesn't even load at the moment because the SQL constraints fail. All it does is clutter up the logs with a bunch of errors, which is rather bad form. You can just get rid of the entire file without side effects.

* The only thing it does do is give an AIUnitType to spies. As spies are not units that can move, this almost certainly does nothing at all.

Ah, thanks for the info, that's good to know! I'll remove it for the next patch


So I'm back to CIV 6 for the first time after the summer patch, and AI+ isn't working. :sad:

When I try to create a new game, it just says 'start game' briefly and then returns to the main screen. I've reinstalled the game and disabled all other mods, and I still get this error. I've uploaded my log files here.

As far as I can see, database.log is complaining that some unit types don't exist.

Hmm. Is it possible that you're using an old version of ai+? I don't think I'm using UNITTYPE_AIR anymore. (though it's odd it complains about that because UNITTYPE_AIR and UNITTYPE_AIR_SIEGE should both be in the latest civ veriso
Try seeing if perhaps you have an old version in your civ mods directory. Deleting that and using the steam version instead may do the trick


Hey guys,
I am trying to alter the mod to make AI using ships and airplanes more often. Re ships - I think of two ways: either special operation needs to be creates e.g. "Naval Assault" where you can put minimum number of ships and force AI to use them. However, I am not familiar with operations node writing so I can very easily mess the whole thing.
Or alternatively I can put max number of ships as non-zero value in current operations and this should also make AI to use them sometimes. However this might change other land operations impacting them in a negative way.

Messing things up is part of the charm!
So yeah I've considered both aswell. I'm pretty sure the non-zero value on standard operations isn't going to work well. If you set a minimum number, they wont ever attack over land. If you dont, its basically free to ignore the ships. In my own tests using that strategy it does end up rarely sending a ship along with an assault if you do set a value. However, it seemed to struggle more with some attacks where it wanted to send a ship along, but couldnt for pathing related reasons (it can get stuck in operations if it cant complete move orders). I wasn't really happy with that so ended up not going for it.
The new operation method is more promising. I've not tried this extensively myself and it can work in theory. The biggest problem youll probably encounter is that there is no good control over what operations are launched when. If you set different priorities, they may either never start the ship operations or may never start the regular operations (even when there arent any ships). If they have the same priority, they may still end up not starting operations (the way it determines when to start what operations is basically a mystery) or theyll be trying to fill up both operations at the same time with recruits, failing on both.
I'd just try it using a best guess on the variables (there are some examples of new operations in my military.xml that may help on the structure), then keep an eye on the game and especially on the logs (especially the operations and behaviortree related ones). Then tweak if it isnt working right. Be especially mindful of the 'priority', 'minoddsofsucces', the allowed distances, and operation limits that are scattered throughout the system. You may need a new category of operations, or could try reusing another. If you reuse another, the game has a tendency to completely some operations

Just make sure to mentally prepare for a lot of test games..
 
Ah, thanks for the info, that's good to know! I'll remove it for the next patch
Messing things up is part of the charm!
So yeah I've considered both aswell. I'm pretty sure the non-zero value on standard operations isn't going to work well. If you set a minimum number, they wont ever attack over land. If you dont, its basically free to ignore the ships. In my own tests using that strategy it does end up rarely sending a ship along with an assault if you do set a value. However, it seemed to struggle more with some attacks where it wanted to send a ship along, but couldnt for pathing related reasons (it can get stuck in operations if it cant complete move orders). I wasn't really happy with that so ended up not going for it.
The new operation method is more promising. I've not tried this extensively myself and it can work in theory. The biggest problem youll probably encounter is that there is no good control over what operations are launched when. If you set different priorities, they may either never start the ship operations or may never start the regular operations (even when there arent any ships). If they have the same priority, they may still end up not starting operations (the way it determines when to start what operations is basically a mystery) or theyll be trying to fill up both operations at the same time with recruits, failing on both.
I'd just try it using a best guess on the variables (there are some examples of new operations in my military.xml that may help on the structure), then keep an eye on the game and especially on the logs (especially the operations and behaviortree related ones). Then tweak if it isnt working right. Be especially mindful of the 'priority', 'minoddsofsucces', the allowed distances, and operation limits that are scattered throughout the system. You may need a new category of operations, or could try reusing another. If you reuse another, the game has a tendency to completely some operations

Just make sure to mentally prepare for a lot of test games..

Hoorah, Siesta is back!
Now we can hope for a new version of AI+)
I made a looot of tests (I almost hate Civ6 by now) for the last two days with AI+, creating a new mod and mixing everything.
What I found is:

1) To force AI to produce ships is relatively easy - just play with pseudoyields either in the base game or in AI+. By the way, looking through the base game code I was impressed that there is no difference in pseudoyields for difficulties/"under siege" conditions and so on. When using AI+ I tried to increase basic pseudoyields for ships (also reduced a bit naval preferences switch bw land and naval units as it is too extreme) to a level of 100 or 200 and it works. However I never saw AI producing aircraft carrier (mb special pseudoyield needed)

2) Just simply including ships in the team doesn't really work. I created the following team with one of the line specifying non-zero ships:
<Row TeamName="Naval City Attack Force" AiType="UNITTYPE_NAVAL" MinNumber="2" MaxNumber="6" />

It would still use the same operation - "Attack Walled City":
<Row TeamName="Naval City Attack Force" OperationName="Attack Walled City" InitialStrengthAdvantage="0.5" OngoingStrengthAdvantage="2" />

Yet, on its own this one doesn't create anything. My AI operations log doesn't show any naval unit included in any operation which means that AI simply ignores this team. As a result of it all ships created by AI are not tied to formation. They can attack enemy ships and even cities sometimes but it will be one unit attack.
By the way I noticed that AI creates aircrafts under "settle" operation, which I am pretty sure means they won't be doing any useful thing on the battlefield.

3) However, it seems that the "Naval team" approach can work.
In couple of my first test games (when I haven't looked at logs yet) I created a "naval team" and also put in "City Defence" operation max number of naval units to 1.
It's probably not the best idea as AI starts building ships when it should be building units. However I think this was the first time I saw naval unit appearing in "AI operations" log. As a result of this operation AI starts accumulating naval units near its cities rather than spreading them across the oceans. That appears to be the main trigger for using this "naval team" formation and I saw couple of great examples when AI used ships, the best example attached (Arabian AI created two fleets and used them in a smart way to take two French cities).
Now I am wondering if the City Defence operation is a pre-requisite to city assault operation. I am not really familiar with behaviour tree nodes but I don't really see any element which would prohibit AI from using ships in a normal operation.
 

Attachments

  • 20170921075446_1.jpg
    20170921075446_1.jpg
    574.3 KB · Views: 179
Update:
It looks like simple shifting max number of naval units to non-zero works with AI+. I don't know Siesta what you did with the behaviour tree, but I finally able to see naval units in AI operations, both defending and attacking cities.
E. G:
67, 2, Attack Enemy City, Operation Recruit, 1 units, Recruited 1, Contract for: UNIT_GALLEY
 

Attachments

  • 20170924100607_1.jpg
    20170924100607_1.jpg
    690.9 KB · Views: 124
@DemonEmperor

The behaviortrees are very simplistic and don't really offer a lot of options. They're indeed essentially linear. The most you can really get out of them is structures like:

state = 1;
if state == 1{
dostuff();
state = 2;
}
if state == 2{
dootherstuff();
}
Honestly I wouldn't bother trying on them too much. Besides not having much of control over flow, the conditionals are extremely limited and the actions basically consist of a few pre determined options only a few ever make sense in their context. They're also combined together using variables held invisibly somewhere in the c++ code that you cant really access. As a cherry on the cake, mistakes here often crash the client, and even if they don't, usually don't really give you any useful info.
Structure wise, you basically have 3 types of xml tags.
1. Definitions /datatypes. You cant do anything with these. It just helps you to see what can be done
2. BehaviorTreeNodes. The meat of the behaviortrees. These form the 'tree' structures and indicate what type of node were dealing with.
3. TreeData. Variables belonging to the nodes. The combination of NodeId and TreeName points to a unique node among the BehaviorTreeNodes. The DefnId shows you what type of variable it describes. Look up what nodetype its refering to in BehaviorTreeNodes, then combine that with the DefnId here. That points to a unique value in the NodeDataDefinitions that will tell you what kind of variable it is. If NodeDataDefinitions mentions a DefnId that isnt used in the TreeData, then you can add it yourself if you want to.

The Jumptos in BehaviorTreeNodes organize the flow somewhat. A node with a jumpto is basically like a set of brackets, starting with the node youre in, ending right before the mentioned node, or if you want, they form a branch. Use a jumpto with the first nodeid no longer in the tree to exit the tree, the operation that this tree was running on will end when you do that. Since the jumptos basically indicate branches/brackets rather than gotos you cant actually jump back to earlier nodes nor can you switch to other branches. Using Concurrent, Priority and Sequence nodes you can create a sort of structure of if statements. "Sort of" because as far as I remember (it's been a while) it's impossible to do proper "else" and "elseif" blocks. I gave up trying anyway

Some node types basically halt execution of the tree until some condition is met. For example, a move to node will not complete until the units have reached their goal. Others basically pass instantly, sometimes unexpectedly. The make formation node for example always passes instantly. If units cant make formations the turn that node is acitvated, the tree will keep going on

If you want more detailed info on any of the nodes in particular I could try and give you some pointers. All my knowledge is experimental/inferred though, so in some cases I don't know what exactly is going on either
Thanks!
More detailed information would be helpful - I'm thinking of making a mod that overhauls the diplomatic and governmental aspects of the game.
A planned component was modular unit/weapon building - e.g. if you want to build a battleship you first need to build a hull, and then add guns. And total tonnage/number of ships could be limited by treaty (mostly on defeats, but also as way to avoid war). same goes for land units.
Was trying to figure out if
1) the AI would be able to handle said arms limitation treaties and actually follow them
2) the AI would actually use the treaties (AFAIK the easiest/best way within the framework is to treat them as diplomatic promises, which I've never seen the AI use with each other)
3) the AI would be able to properly handle the diplomatic repercussions of breaking a treaty (against another AI, would be insta-denounce unless they're declared friends)
 
Ok, after several tests I got the following:

The whole decision whether to use naval units at city siege is decided by "OpTeamRequirements".I put maxnumber to 4 for naval units and had lots of fun on small islands map.
Persian AI took 3 civ almost entirely by building fleets of frigates and caravels. So I can conclude that normal attack city behaviour tree is working good for ships. There is however two problems:

1) AI doesn't distinguish between naval melee and naval ranged units. In some situations naval ranged units can bombard city for a number of turns without taking it with melee ship/unit.
I suspect it is because I removed minimal requirements from land melee units. There is a split required for naval_melee and naval_ranged in tea to make sure at least one melee ship/unit is participating.

2) AI doesn't distinguish between coastal and non-coastal cities and that's a bigger problem. AI can get a solid pack of units to the siege but ships won't be able to reach the city. That doesn't block AI from starting the attack but obviously chances to take that city are small.
In my opinion there should be an "if-function", saying something like:
a) If target city is coastal, then delete "city attack team" and use "coastal city attack team", which allows to use naval melee and ranged units. (or alternatively to check if there is a direct naval route to the target city)
b) If target city is within one cell from sea, then use "naval bombardment team", where you can include a couple of ranged ships to help landing melee units.

Alternatively the whole "city attack" tree can be recreated (in the manner similar to "zergrush" ), but again somewhere there should be a condition checking the target city.

My problem now is that I don't know how to code that condition ;)
 
By the way, looking through the base game code I was impressed that there is no difference in pseudoyields for difficulties/"under siege" conditions and so on.

Yeah there's basically nothing in the base game that makes them produce more or less units on a pseudoyield basis. They do build/more less based on the presence of operations, but only if the pseudoyields are high enough.
Make sure to keep in mind that the pseudoyield value of the yields table is multiplicative and the pseudoyields attached to strategies are additive.


Update:
It looks like simple shifting max number of naval units to non-zero works with AI+. I don't know Siesta what you did with the behaviour tree, but I finally able to see naval units in AI operations, both defending and attacking cities.
E. G:
67, 2, Attack Enemy City, Operation Recruit, 1 units, Recruited 1, Contract for: UNIT_GALLEY

Are you sure it doesn't work straight out of the box? I've not done anything specific to make this possible and have seen the behavior for a while. Ships do rarely attack in general with AI+ on. It just isn't very often/reliable nor very effective.

AI doesn't distinguish between naval melee and naval ranged units. In some situations naval ranged units can bombard city for a number of turns without taking it with melee ship/unit.
I suspect it is because I removed minimal requirements from land melee units. There is a split required for naval_melee and naval_ranged in tea to make sure at least one melee ship/unit is participating.

You can attach your own aitypes to units and use those instead of the standard ones if you want a split. It doesn't always work perfectly (they still wont build most support units despite my best efforts), but it can get you somewhere.


AI doesn't distinguish between coastal and non-coastal cities and that's a bigger problem. AI can get a solid pack of units to the siege but ships won't be able to reach the city. That doesn't block AI from starting the attack but obviously chances to take that city are small.

Yep.. In my experience it does sometimes actually prevent it from attacking when the cities can't reach it, and is the main reason I haven't just added the naval ships to the operation. AIs basically end up wasting resources to build ships that will actually make attacks on land cities less likely to happen. There is as far as I know no way to code any conditionals in so were stuck there. With purely new operations like the zerg one (which is basically turned off now btw), you at least prevent the normal attacks from being less effective as long as the new operation never launches.
Man, all of this would be so simple with access to the actual code / with a good lua api.

Hoorah, Siesta is back! Now we can hope for a new version of AI+)

Just here to answer some questions at this point :) I don't have anything planned for AI+ atm and don't anticipate doing much beyond maintenance until we get better tools. If you're curious I'm building a Dota 2 bot right now, which actually allows coding with a pretty good API and proper debugging tools. It's a lot more fun to work on that.



Thanks!
More detailed information would be helpful - I'm thinking of making a mod that overhauls the diplomatic and governmental aspects of the game.
A planned component was modular unit/weapon building - e.g. if you want to build a battleship you first need to build a hull, and then add guns. And total tonnage/number of ships could be limited by treaty (mostly on defeats, but also as way to avoid war). same goes for land units.
Was trying to figure out if
1) the AI would be able to handle said arms limitation treaties and actually follow them
2) the AI would actually use the treaties (AFAIK the easiest/best way within the framework is to treat them as diplomatic promises, which I've never seen the AI use with each other)
3) the AI would be able to properly handle the diplomatic repercussions of breaking a treaty (against another AI, would be insta-denounce unless they're declared friends)

Interesting idea, but I'm afraid it's highly unlikely you can do this without access to the game code / without the devs making some way to use lua code for AI. Behavior trees at least don't allow you to code any of the important steps. They don't have a conditional for diplomatic promises, nor one that counts the amount of ships. And while you can kind of force unit builds with behaviortrees, you cant make them not build units, especially not in such a subtle way where they may consider whether it is worth the diplomatic penalty. There's not even any support for custom variables in behaviortrees.
 
Any chance for an update compatible with the Fall patch? The unmodded AI still seems to be far too friendly....
 
Having a look right now to see if anything needs changing / whether there are new tools to work with.

Edit:
Looks like it at least doesn't crash the game. Competence has yet to be evaluated.

Toolwise I don't see anything fundamentally new, but it seems there a couple of small additions to the xml toolset which is always nice. Mostly to support the new naval operations.
There are also a couple of additions to the strategy conditions. There are now entries for classical/medieval/industrial eras on top of the renaissance/modern that were already available. Should allow for some finetuning of build desires etc. across the ages.
 
Last edited:
Back
Top Bottom