As promised in the Long Ago times of DevLog #2 (found below) I wanted to go over some of the interesting specifics of how the Ai was built for Dread Admiral.
https://steamcommunity.com/app/4492990/eventcomments/586181370788765462/
As a rough reminder, there are four 'layers' of Ai, each hand programmed to coordinate with eachother.
The Command layer -> Determines goals and production
Fleet Layer -> Calculates optimal fleet configuration
Move Layer -> Moves units towards their goals, min/maxing their ability to attack and defend
Combat Layer -> Calculates the next optimal move in combat
Today we'll be focusing on the Combat Layer, as going bottom up is also how I designed the AI piece by piece in the first place. By designing bottom up, I had an accurate idea of what the layer needed and/or was going to do, and could see that bit of gameplay before working to the next phase. E.g. Combat I can just spawn some ships and see if they do the right thing. For Move I need to spawn them away from eachother. For fleet comp I then got Quick Battle working and had it counter-pick me, and for Command - well now it has to do a full battle and manage cities!
-- Combat at 10000 feet --

Combat has some top level objectives it needs to meet to be convincing:
Act intelligently for alternating activations
Pick optimal targets
Order the activations to minimize kill-stealing
Try not to waste your planes.
To handle this, I built 'ActionSummary' objects that perform all of the evaluations of a given attack - the target, the attacker, whether they're 'at risk', the flak incurred (if applicable), and various other evaluation metrics to tweak it. These summaries are then cached for future use to reduce repeat calculations.
Then the actions are reduced to a single evaluation metric and ordered by that number. Each one of these actions is taken *entirely* in isolation of the future activations of the Ai, which means that it must act intelligently enough to seem like that is not the case. Every once in a while though, you'll see it spread damage out in an unintuitive way - and this is largely why. It's not a cohesive brain, but a series of small moves taken in isolation, but attempted to be ordered in such a way as to be close to optimal.
-- At Risk Units --

Units are 'At Risk' if they can be destroyed in a single activation. Indeed, much of what makes the combat deep is noticing and weighing whether you can kill that CVL before it attacks, attempting a high-roll to cut off an activation or going for a Hull Breach to cut off an activation.
The AI just focuses on the original version - no variance, no veterancy, no crits. "Can you kill me in the next activation?" These get priority over all other actions as it is the 'most intelligent' move in many cases. This can result in oddities of course, largely when Supercarriers threaten that many units are at risk, or when it sees a CVL is at risk at the same time as a Cruiser who is at 3 HP, activating a relatively safe CVL over the Cruiser because the risk of losing that high end activation is too high.
There are some bugs with this, the most obvious being the SBB, as the Cruise Missiles/Broadside having different ranges, among other things, meant I took a lazy approach. This is obvious when the Ai skips an activation with a Carrier at 11+ HP, not realizing that it's basically already dead. Same can be said for Crits.
-- Optimal Targets --

There are many things that define what optimal should be, the first and most important (that works far better than it should) is simply Cost Per Hp * Damage. In general, this is what we're optimizing for as well. It's not a perfect metric, and many of the other pieces of logic are dampening this high weighted metric; but this naive implementation does reasonably well.
Various other things that contribute:
Flak or How many planes will I lose? The Ai counts losing planes as "reduced value' in the Hp Cost function above, so the more planes it expects to lose the more it reduces the value of that action. This is why putting up Patrols often causes them to attack something else, or the patrol itself! Interestingly, before many other metrics were involved, this naturally helps the Ai focus-fire when it comes to using Planes, because the optimal targets for damage/flak remain similar between activations.
Intercepts - similarly Planes are somewhat valuable to the player, so it is often easy to get exaggerated value out of destroying planes because the AI views them as being worth about '$2'.
Carriers - each plane a Carrier lacks reduces its perceived value as well! A carrier with an empty deck is worth much less than one with a full deck. You can even find your CVLs ignored for more regular targets at times simply because they don't have any planes left.
At Risk - Player units at risk get a much exaggerated value. Rather than just being their Damage * Cost per HP, they get a bonus equal to their *entire* value. This means that while a PT boat is at risk, it is often ignored, but a Battleship at 3 is worth $30+, making it very juicy.
Damaged Units - The Ai gives a small bonus to shooting at units already damaged, helping it to focus fire. This bonus is kept very small so that the focus fire doesn't distract it from juicy targets however.
Number of Targets - The Ai gets a small malus based on how many targets the unit in question has. This is to help reduce kill-stealing, especially among battleships and cruisers. Activating the unit with only a single target vs the one with two targets makes it less likely that we'll remove one of our own activations unnecessarily.
Overkill - The Ai also gets a small malus for the amount it will overkill a target. I had found at some point that Battleships would often get priority to finish off something that a nearby Cruiser would finish off, so this malus helps min/max the damage output to prioritize exact damage.
I'm sure I'm forgetting some as well. The point in the above is that a great many factors are crammed in to help get small optimizations out of the Ai's attacks to minimize the amount a player will see it do something 'dumb' and hopefully provide adequate challenge.
-- The value of 'Fun' --

This could be cope, but I'm too deep huffing copium to notice.
An example of a suboptimal move that has been exaggerated purely for entertainment value is Interceptors. I think a great many cases where the Ai intercepts it would be better off bombing (in fact, I'm reasonably sure about it given that I used to calculate what its 'actual value' was.) Intercept 'value' is often going to be close to zero since both sides lose several planes. By weighing it higher, the player gets more points of interaction with their patrols and has to think about them.
Things like multi-action units occasionally having their values misunderstood, an AI killstealing itself, or spreading its damage - as long as it doesn't occur too frequently, gives the player little edges to exploit and feel smart about taking advantage of. Certainly it's been rare for me to hear that the Ai is poor in combat and that the game is too easy haha. What's more - each improvement or bugfix I do in this area technically increases the difficulty which has been unnecessary for some time.
With that, I think this first deep dive on the Ai can be concluded. Each layer has a great many of these hand tweaks, considerations, and overrides in place to try and make it play a mix of 'optimal' and 'interesting'. A future improvement could be having some Ai's do more focus fire, some play more cagey, or similar; but the original goal was simply to make it engaging and threatening.
If you haven't - consider dropping into Steam Discussions or in the Discord to chat strategy or keep up to date on all things Dread Admiral, Cheers!