Assertive Seawall AI

Discuss Assertive Seawall AI

1 Like

Several big updates to ship behavior and tower placement. AI now patrols the water with multiple ships (more per age) and can send multiple ships to make island landings. Tower placement on islands is weighted to be toward the coast instead of the AI’s base, and to use them to defend docks.

I’ve had a lot of success implementing ideas so far (at least by my standard) so if you have any balance suggestions or tweaks I appreciate any ideas!

I played some games with the new version of the ai, here’s the feedback. All of this was on Caribbean, haven’t tried on hybrid maps:

  • AI seem to prioritize creating fishing boats rather than warships, only building them, it seems, after they reach a certain amount of fishing ships. They won’t even build warships when I’m raiding their fishes. I think they should prioritize having 1 or 2 warships before committing to a fishing, and they should be able to garrison inside the dock, as right now they just keep on fishing or try to unsuccessfully run away. Its far too easy to send 2 warships as a third shipment and completely negate water to the AI.

  • AI seems to try to build docks in the same spot where I just destroyed their old dock, wasting time and villagers in the process. Eventually they do change position, but once you find that spot, you can destroy it easily as it will always prioritize fishing, and if you leave your warships defending that shore, it will then take some more time to get a third location, which will prioritize fishing, and so on. I think AI should change their docks position as soon as their first dock is destroyed, not try no buld it there again a few times. Also, all new docks should prioritize warships first.

  • I keep seeing enemy armies deployed on islands that can never make a return, as no ship ever tries to take them home.

  • AI do build towers and their equivalents near docks, but they do it after building the dock, even when trying to rebuild a dock with my warships nearby. Maybe make it so they prioritize coastal defences too? Right now, it has been very easy to just destroy the outpost foundations because when they start building them, I already have a sizeable navy. Also, having them ship fortresses, maybe even 2 times, would help a lot with coastal defences too.

And right now,that’s it, I would like also for the ai to build defences and maybe a base in other islands, but that’s something more complicated, maybe down the road. I’m eager to try a new version already!

1 Like

Thank you for all the awesome feedback! What difficulty are you playing on? Some of the parameters are difficulty dependent.

I’ll take a look at the priorities. I might be able to force them to make a couple ships first, or change the priority so they make warships first. I haven’t looked at this part yet so I’m not sure what it will look like. I agree though, the AI should be trying to dominate the water.

It’s possible they are in the queue. The AI bases its warship building on how many ships it sees you have, but it takes time to train them. Regardless it sounds like I need to make it make more ships.

I know where this chunk of code is. I’ll have a look and see if I can change that decision making.

Hmmm I’ve seen it change in my testing, but I think it sometimes just doesn’t have many choices. I can probably force it to make a new choice if it chooses the same original spot. I’ll give that a try. This has been a particularly annoying thing to solve.

Right now they build closest to the nearest fish, and then randomly after that if they are spotting your ships. Would you want to see more randomly placed docks?

I’ll see what I can do.

I’ve seen parts of the code to get explorers back. I wonder if all attacks are considered suicide missions… Maybe I can repurpose it. I’ll have to see.

With the way I’m doing it I can’t build the outpost first. I’ll keep playing around with the priority. I’ve seen some outposts get put on the coast on their own, but it’s a tricky balance. When I started they would stack all 7 outposts as close to the dock as possible.

Do you mean forts and TC’s, or artillery? I guess I’ll look at all of them, but I’m really hoping I can get them to stage artillery on the coast.

I would also like that! It’s a bit down the road, though. The dream is to get the AI to play on maps like Archipelago and Ceylon, building whole new bases and economies on different islands.

Im playing on hardest! I can try extreme too to see whats up.

Maybe not make them but make their first shipment at age 2 be a warship shipment. That way they don’t commit too much wood on building a navy.

Maybe not more randomly placed right now, but make the ai change the location after the first attack. As of right now, they will change the location only after commiting a few villagers to die to my ships because it insist for a few times to build the dock in the same place. The change location, but takes too long to make the decision. Maybe make it so ai doesn’t build docks near enemy ships?

Me too, but very late in the game. If they were ready earlier in the game, they would have a better chance to repel invasions.

I was referring to Forts, Tcs and outposts, but if you can make it so they have artillery ready, that would be amazing!

If this can be done, my long-awaited dream from TAD of playing Ceylon as it should be would be met. Hopefully it can be done!

1 Like

Any difficulty is good! I just want to know so I don’t go tweaking the wrong one. I’ll go through and respond line by line tomorrow, but I went through and incorporated all the low hanging fruit and uploaded the changes. I even had a game vs. Henry the Navigator and lost the ocean for the first half. It tapered off since he devoted a lot of resources to ships but I dialed it back to a level a little higher than normal military (I think). It’s a balance between making enough ships without crippling their economy.


Change summary:

Fixes and tweaks to tower placement, dock placement, and warship building priorities as they relate to fishing ships. AI now prefers to build town centers on the coast and next to docks.

1 Like

It’s a great tactical decision. Hopefully there’s an abstract ship shipment category, otherwise it might be a ton of work.

I was able to make a check to not use the original starting dock position when warships are spotted. I’m going to change the initial position also to be next to the initial water shipment point. From what I’ve seen that point is always between the islands, so it’s a better place to build docks for warships than the backside.

I can probably adjust the outpost build priority or even reserve resources for the first couple.

I was able to get TC’s done! At least the placement. I don’t know if the AI makes a lot of TC’s anyway. The cool thing too is that Henry the Navigator made a TC on the dock, accompanied by a whole forward base. It was a whole coastal base by the time he was done with a barracks, artillery foundry, two docks, a tower and couple other things.

I hope so! I noticed TC placement was restricted to places somewhat close to the starting base. Unfortunately I think I need to come up with a whole transport plan though to get it to go to another island.

1 Like

Hey nice work! I thought about modding the AI, too, but I refrained from it because I’m fairly convinced that the devs are currently actively maintaining the AI and we just have to be patient. The things they did for the AI in 3DE are massive and, dare I say, very good.

But I really love it when I see other people modding the AI! I’m looking forward to seeing more updates from you!

Unfortunately? I don’t understand. Does it break something if you use a transport plan?

1 Like

Thanks! Maybe if the devs are working on naval AI they’ll DM me so I don’t spend too much time on it, but I also know the focus has been on land. Everything I’ve written should transfer without too much effort, so short of a full naval rework I’ll probably be ok. It’ll say something like “build towers close to base” and I’ll add on “jk if it’s an island map do the opposite”

I just mean it’s a lot of code I don’t fully understand yet. I need to transport villagers and/or an explorer, build a town center, do some other things… though maybe it’s enough to just transport villagers. I’ve seen that once a new TC gets built it’ll build a whole new town so maybe I just need to transport some villagers and that’s it.

To be honest, I have no idea about the Ceylon gameplay.

However, what I am 100% sure of is that all bots should immediately migrate to the big island when the game starts in Nomad mode. This one should be super simple to do.

I guess more brainstorming is needed for the non-Nomad part. Coding should not be too difficult once the general gameplay is figured out.

1 Like

Sounds like some famous last words!

I don’t yet know of a way to call the specific map type. I’ve been writing everything as an island map or naval map. I was thinking the conditions would be tied to the natural resources, so if the AI starts running out of wood, food, or gold on an island map they’ll create a transport plan to land somewhere else. I’ll take a peak at the conditions to start building mills and probably borrow some of that. Once I get villagers moving I can fiddle with the distance measurement of the TC builds so hopefully they’ll just use the villagers on the new island to build another TC.

EDIT: lol, what the heck just happened to the code :joy: I meant to use the Logical Type Land Military constant.

You know, I actually take it back. I clearly remember that it’s very frustrating to handle different plans across islands. The thing is, if you just create a combat plan and say “yo, dear AI, please aiPlanAddUnitType(plan, ################################# 50, 50, 50)”, the plan will grab 50 military units regardless of whether they are on the same area group or not. It resulted in a bunch of units trying to reach the opponent’s island. The poor guys can’t swim :slightly_frowning_face: But I maybe the devs fixed it?

But anyway,

Do you customize the build plan or do you use the functions the devs made? Can I see the code?

1 Like

I stick with the functions the devs make as much as I can. I’ve mostly been toying around with the priorities, placements, how many they make, etc. Some of the things were like “don’t make more than 1 caravel” and I changed that to “go ahead and make 3 frigates”.

The easiest way to see the code is to subscribe to the mod and open up the local folder. None of the files are packed away or anything so they’re easy to open up. Otherwise I’ll upload another copy here when I get back onto my PC. I comment my edits with the same sentence (usually verbatim) on the changelog, but I’m starting to think I should tag all of my edits with my name so I can keep track of what’s what.

That looks workable. I thought I saw something where you can set the pickup location but maybe not. Hopefully I can just tell it to only grab villagers from the starting island and make it a one-way street to the mainland.

These all go in ai/core/
aiutilities .txt (69.1 KB)
aimilitary.txt (235.9 KB)
aiExploration.txt (50.1 KB)
aieconomy.txt (138.1 KB)
aibuildings.txt (154.9 KB)

I kept testing, i have here 3 recorded games, against Ethiopia, USA and Spain. I found some behaviours kinda inconsistent, for example, the ai wont always build docs in different places, as in the Ethiopia game. Also, only in one of the games did I saw the ai building outposts to protect docks, and even then they did it too late and my ships destroyed it before it had been built. I will test against Portugal too, as their ability to have extra TC’s might make the changes work better.
AssertiveWall Ai Spanish vs USA.age3Yrec (9.0 MB)
AssertiveWall AI Spanish vs Ethiopia.age3Yrec (8.6 MB)
AssertiveWall Ai Spanish vs Spanish.age3Yrec (8.7 MB)

I see what’s happening. Spain and Ethiopa kept building docks in the same place because they couldn’t see you. The docks are what provide all the LOS, so once they get destroyed the AI doesn’t know there are ships there. I might have to make a different condition if this one winds up behaving poorly.

Spain and Ethiopia also built a lot of stuff, including a dock before aging and sat there idle for a long time.

USA fared a little better but had the same issues with aging up.

I put the age up condition into the dock building directly. I also tried to set a high build priority for the first tower, but I think I was editing the old AI or something so those changes didn’t make it. Changes now uploaded

1 Like

Amazing, I appreciate the fast responses and updates! I’ll give it a go and get back to you.

1 Like

I appreciate all the play testing! It takes a long time to play a game at regular speed so most of my testing is done with cheats. I did play against Hiawatha on Expert just now and he beat me to Age 2 (sub 4:30) with 2 docks and a war hut up before 7 mins.

I’m going to keep going with modding this AI until one of us loses on Caribbean. Then It’ll be time for Ceylon (assuming Amazon works fine).

Edit: I found where the rest of the tower logic is kept. right now the AI won’t build a tower in age 2 if it’s in an offensive posture, and won’t start building in the other postures until it makes it to Age 2. I’ll definitely be able to update this so it builds towers in age 2 on island maps regardless of posture, and even during the transition to Age 2. I can also set the priority high so it tries to get it down ASAP as soon as it has a dock.

Looking forward to that update! I made some time to #### # matches with the current version, and now they constantly age up at a competitive time, so that’s good. The bottleneck right now is the AI making docks in other places when their OG dock is destroyed and getting those outposts up faster to counter my raids in their waters.

What I usually do is leave a ship or two in the latest place I saw a enemy dock, so maybe if the villager LOS catches an enemy ship, cancel the building? Not sure if its possible. I have also noted that many times, destroying their only dock and not letting them build another severely hits their economy, as one might expect, but it also seems it disrupts their ability to create villagers? In many landings I haven’t seen as much vills as I’d imagine. In any case, here are the tests, so you can see it by yourself too.
AssertiveWall aAi Spanish vs Malta.age3Yrec (6.5 MB)
AssertiveWall aAi Spanish vs Inca.age3Yrec (9.0 MB)
AssertiveWall aAi Spanish vs Dutch.age3Yrec (9.4 MB)

1 Like

Ok, I think I finally wrapped my head around these Monitor functions. Take a gander at the latest update and let me know how it goes.

I’m super excited about this one. I think I was able to fix a bunch of the issues with the logic, though there’s still plenty of tweaking to do. Docks and towers should now finally be getting built in the transition to age 2, and the AI should finally try to move docks if they can see any enemy warships (though I’m hoping to make that logic more advanced in the future).