Tactical Combat AI Mod

A place for discussion of making game modifications.
User avatar
harpy eagle
Posts: 296
Joined: Sat Mar 10, 2018 3:25 am

Re: Tactical Combat AI Mod

Post by harpy eagle »

Update (27c2b17):
  • AI attempts to account for enemy ship movement when determining if it is at risk from assault shuttles or missiles/crafts when reserving PD.
  • Removed the simplified algorithm for PD allocation. It's been around since the very first version of the mod, and now that the AI is better able to weigh hostile missiles/crafts against ships I don't think it's needed anymore. Removing it does seem to improve the AI's handling of ships that are equipped entirely with PD weapons, or missile fleets that have run out of missiles.
  • Fixed a stalemate bug that occurred when all crafts and all non-PD weapons on all ships have been destroyed.
zolobolo
Posts: 1544
Joined: Fri Nov 25, 2016 3:49 pm

Re: Tactical Combat AI Mod

Post by zolobolo »

harpy eagle wrote: That's a very interesting failure. I'm not sure why the destroyers did not attack the bombers, nor why they stopped attacking the planet if the carrier had significant shield regen and barely any craft left.

I'd have to see what the most significant factors in their decision making were to know for sure what to change. Are you ok with providing another save file?
Sure can, please find the save below - the unlimited undo feature is every software testers dream but I guess sometimes it also makes the save files a tad too large for the upload :)
https://www.dropbox.com/s/fh1owkinji2bz ... g.rar?dl=0
zolobolo
Posts: 1544
Joined: Fri Nov 25, 2016 3:49 pm

Re: Tactical Combat AI Mod

Post by zolobolo »

harpy eagle wrote:
zolobolo wrote:- Carrier should close in during second phase like the military transport does to support other fleet elements during the final phase
Fair enough, though I not sure at this point for how the AI should think about this. Perhaps the AI should only enter stand off and bombard mode if it has overwhelming missile/bomber firepower relative to PD?
Yes, but even then it needs to get closer to the target as there is no downside to that but lots of pros

It would be a sensible rule for carriers to always close in on their target just to the point where they are not yet in range
This would enable them to stay out of starbase and PD fire but still effectively support friendly ships by reducing their turnaround speed and generally attacking together with them instead of before them (if bombers prioritize the bases and PD to early) or after them (if the carrier lags behind and only close in once every other fleet element has already been destroyed.)
zolobolo
Posts: 1544
Joined: Fri Nov 25, 2016 3:49 pm

Re: Tactical Combat AI Mod

Post by zolobolo »

Here is an example where several range and positioning related topics are visible at the same time

The first line of attackers are within range of the star-bases guns. Their shields are able to absorb the hits so not a big issue for them though. It can even be a great tactic to bait the player into pumping damage into their shield instead of into incoming small crafts and missiles

Second line of attackers does not move into the same range for some reason. They have Pulson lauchers so it seams that they are the reason for the bombarding timer running (the situation visible is running for around 12 turns) but are out of range from the starbases

Fleet carrier stays in its initial starting position - as discussed above, it would be best if these ships would move as close as possible to their target
Attachments
Positioning.png
Positioning.png (1.15 MiB) Viewed 13189 times
zolobolo
Posts: 1544
Joined: Fri Nov 25, 2016 3:49 pm

Re: Tactical Combat AI Mod

Post by zolobolo »

Can you make it so that the standoff timer is only applied for heavy weapons sieging starbases or planets?

It is putting the attacker into a disadvantage when has rockets as it closes in with 0 munition in the end
In case of small crafts, these should not engage starbases on their own due to their PD power + shield strength and thus should also not trigger standoff

Below is an example where during standoff all carriers stay behind (some squadrons have been lost as they sortied out) and all other ships move into the range of the starbases but do not attack. This seems to be due to the standoff timer but is very unfortunate for the attacker as the ships in the front cannot resist the damage dealt to them and once they move in, they do not have the support of the carriers.
Attachments
Standoff.png
Standoff.png (1.18 MiB) Viewed 13184 times
User avatar
harpy eagle
Posts: 296
Joined: Sat Mar 10, 2018 3:25 am

Re: Tactical Combat AI Mod

Post by harpy eagle »

zolobolo wrote:Sure can, please find the save below
Thanks, trying to diagnose a problem without being able to reproduce it is like trying to walk through a building with your eyes closed.

Re: stand off distances, I'll look into it. For now as a stop-gap measure I'm just going to revert to the vanilla behaviour of ceasing all ship movement whatsoever:
CombatAIMod (76a099e).zip
(12.53 KiB) Downloaded 447 times
User avatar
harpy eagle
Posts: 296
Joined: Sat Mar 10, 2018 3:25 am

Re: Tactical Combat AI Mod

Post by harpy eagle »

zolobolo wrote:2. The top and bottom destroyers move in to attach the carrier - sub-optimal considering its shield and the bombers at hand
Ok, for this point it was pretty easy to see that the reason the top and bottom destroyers did not attack the bombers was that all of their weapons face forwards and so when they move forwards, they are unable to shoot at the bombers anymore.

The simple fix seemed to be to allow the AI to consider moving towards hostile missiles/crafts in addition to ships, however as I was implementing it, I ran into this issue with the built-in find_min_facing_move_L2() function:

Image

This is a problem with a C++ function so unfortunately there's nothing I can do unless sven changes it.

As for the rest,
zolobolo wrote:1. Finish off the carrier before moving in to eliminate the planet defenses and stay out of range until then
I think this is pretty much the core of the problem. Even though the carrier has gargantuan shield regen, if the attackers had not tried to fly past it to attack the planet they probably would have been able to finish it off pretty well.

The AI simply doesn't know that in order to get to the planet it has to fly past the enemy fleet. If it had been engaged with both the carrier and the planet right from the start, I think it would have been making the right decisions. But the fact is that the planet is not really relevant until after.

I really want to avoid things like having to check if any of a hostile ships weapons can attack any friendly ship when calculating priorities, but if it doesn't add too much complexity to the code I think I may have to make an exception for immobilized objects.

Of course then defenders with an inferior fleet flying away from their planet to attack becomes the next problem... I think we are really starting to get into issues with ship positioning here, which is a little beyond what I envisioned for this mod. I think planetary attack and defence is an important special case so I will see if there's anything I can do with prioritization that will alleviate that, but for the most part if it can't be solved by target prioritization it's probably going to be left for a different project.
zolobolo
Posts: 1544
Joined: Fri Nov 25, 2016 3:49 pm

Re: Tactical Combat AI Mod

Post by zolobolo »

harpy eagle wrote: For now as a stop-gap measure I'm just going to revert to the vanilla behaviour of ceasing all ship movement whatsoever:
Workaround is working as intended, but will not make any difference in the outcome :)

If you would like to make the vanilla move behaviour work correctly, I would try the following:
- Remove standoff rule from all cases except for heavy weapon outfitted attackers
- Block bombers from being sent out for at least the first turn and for at least 3 turns if there are only star bases defending the planet (so that the carriers have time to get in range, soak up some fire and give time for rockets to arrive and soak up additional PD fire)

Cant say yet how much the new movement rules have added to the overall performance of the AI but suspect that not much (even outside of planetary invasions)
The most effective measures in my opinion in descending order:
- Reservation of PD fire (this is a game changer once close combat phase kicks in as previously they were just soaking up all torpedo, rocket and bomber damage directly)
- Dynamic target selection: this has made the AI a bit unpredictable (a very good thing) and you cannot manipulate them anymore by simply presenting a ship to shoot at. The AI will mercilessly go for the juiciest target, and even though this has some oddities in planet invasion, it greatly enhances difficulty and fun factor thereof
- Assault Shuttles - This element has great potential but is currently held back by the reserved PDs :) and their often long engagement distances where they are usually picked off (maybe they should always go last after missiles and other crafts have launched)
- Smart MGMT of Interceptors: same as PD but even more effective (until fighters are not picked up themselves by PD:))
User avatar
harpy eagle
Posts: 296
Joined: Sat Mar 10, 2018 3:25 am

Re: Tactical Combat AI Mod

Post by harpy eagle »

As a quick though crude solution to planetary attacks I made it so that ships always consider planets as the lowest priority when deciding what to move towards.

Interestingly, even when the attackers focus on the carrier they still can't kill it, and lose. So I'm starting to think of this combat as a less significant corner case. The attackers really are outmatched here, and no matter what they do I don't think they can win. They simply cannot beat the shield regen of the carrier and it defeats them even after losing all it's crafts (shield regen is really OP...).

Still, I'll keep the crude hack in case it improves planetary attacks elsewhere. Since it just short circuits the AI instead of calculating a proper priority it may make the AI worse if you outfit your planets entirely with missiles or torpedoes.

Also, should space stations be included or should it only apply to planets?
Attachments
CombatAIMod (61ee17f).zip
(12.64 KiB) Downloaded 413 times
zolobolo
Posts: 1544
Joined: Fri Nov 25, 2016 3:49 pm

Re: Tactical Combat AI Mod

Post by zolobolo »

harpy eagle wrote: Also, should space stations be included or should it only apply to planets?
It sounds like a good idea for planets for sure. Even if they have torpedoes - like mentioned above - the PD reservation and fighter interception rule is pretty much king now and protects the fleet very well.

In case of space stations: it probably makes not difference either way. If they are not targeted, first they will get rockets and bombers attacking from there but PD and fighters can now handle this.

A player might try to cheat the system by moving ships close to the bases or even behind them but that is the only case I can think of where this is would be a problem.
zolobolo
Posts: 1544
Joined: Fri Nov 25, 2016 3:49 pm

Re: Tactical Combat AI Mod

Post by zolobolo »

harpy eagle wrote:The attackers really are outmatched here, and no matter what they do I don't think they can win. They simply cannot beat the shield regen of the carrier and it defeats them even after losing all it's crafts (shield regen is really OP...)
Agreed. Worse: most of the movement AI issues could be solved with weaker shields (due to regen rate and directional protection)

Care to make a shield re-balance mod? Would probably go well with your Combat Damage Mod as that one increases survivability of large ships, while this would nerf their shields and equal the balance out

Currently the scaling is incredibly rapid to larger hull sizes:
Size - Shield strength - Number of slots - Base recharge per turn
Small - 40 - 1 - 10
Medium - 80 - 2 - 40
Large - 160 - 3 - 120

This of course means that larger vessels can absorb x12! more damage and recover absorption potential x12 faster - not even counting rotation exploit
As large vessels tend to pull more heavy mount hits on them, it is ok if their base shield power increases with size but the recharge rate is just off the charts, even a Plasma cannon designed to take down shields can only do max 50 damage and you basically need x2.5 of these bad boys each turn to even be able to do hull damage

I think this can be resolved by giving 25% envelop effect for all energy weapons and changing recharge rate something like this:
Old - New
0 25% 10% (recharge rate for around 1 Plasma Gun per Turn)
1 63% 20% (this makes Shield Regenerator a viable option as it adds +48 absorption per turn bu still no OP)
2 81% 30%
3 91% 40%
4 95% 50%
5 95% 60%
The above would be intuitive I think and since it doesn't really matter for a small ship if it regens 10 or 4 shield per turn, it would only affect larger ships to resolve their OP stance and help the AI to perform better (focused fire is less of a must and thus benefits individual targeting like your script does)
User avatar
harpy eagle
Posts: 296
Joined: Sat Mar 10, 2018 3:25 am

Re: Tactical Combat AI Mod

Post by harpy eagle »

That sounds like a good thing to try. Reducing the global shield regen percentage is easy, here is a small mod that does just that:
ZoloboloReducedShieldRegen.zip
(821 Bytes) Downloaded 435 times
However, if the problem really is how shield regen scales up with hull size, then changing the shield regeneration percentage globally will fix large ships but will also unfairly nerf medium and small ships (EDIT: there's more to it than that, see my later post). I think it can matter whether a small ship regens 10 or 4 shield per turn, especially is very small encounters. And changing the global regen percentage also affects medium ships.

What I'd like to try is scale between 25% and 10% base shield regen depending on the shield generator's size (which is what determines how much shield it gives you). So instead of regen being a pure percentage, it's scales up with the size of the mount but has diminishing returns.

Then I suppose regenerators would multiply that base regeneration rate up to 60% of the total shields, as you have in your table. That will also mean that shield regenerators help smaller ships more, but since they also have less slots I guess it's fair?
Last edited by harpy eagle on Thu Apr 05, 2018 12:16 am, edited 1 time in total.
User avatar
harpy eagle
Posts: 296
Joined: Sat Mar 10, 2018 3:25 am

Re: Tactical Combat AI Mod

Post by harpy eagle »

Okay here it is:
ShieldRegenMod.zip
(751 Bytes) Downloaded 427 times
Changes shield regen so that instead of a percentage, the amount of shield regenerated each turn is 1.6*SQRT(adjusted max shield).

The adjusted max shield value is the vanilla ship property that produces the maximum shield value of the ship, adjusted for shield generator damage.

Personally I don't like the idea of shield regen scaling up linearly with total shield, as is what happens when you use a percentage. While you could argue that a ship's survivability increases linearly with it's shield (twice the shield, twice the damage that has to be dealt to get through the shield, ignoring directionality), the effect that shield regen has on survivability is not linear at all, but instead is proportional to the number of turns a ship will have functional shield generators.

I think this is the original mistake vanilla made with shield regen.
User avatar
harpy eagle
Posts: 296
Joined: Sat Mar 10, 2018 3:25 am

Re: Tactical Combat AI Mod

Post by harpy eagle »

Update (6f23070):
  • Direct fire weapons now also consider the amount of missiles currently launched at a ship when deciding to target it
  • Defence value calculation now includes the amount of useless system health (bulkheads, etc) that might soak up system damage
  • Combat boarders now use boarding priority to pick the ship they move towards (note that all ships still only ever pick the best of the closest 3 when deciding what to move to).
  • Planets are now always considered lowest priority when deciding what to move towards, unless if they are already in weapons range.
  • When deciding to attack missiles/craft or reserve PD for unlaunched missiles/craft, the amount of damage the weapon does vs the amount of damage the missile/craft group does has more weight (It's now calculated as missile damage/weapon damage squared).
Update (bbae9ca):
  • For the last item above, now only the individual missile/craft/weapon damage is squared, since the count of missiles/craft can be unreliable. For example if there are multiple craft groups near each other, or multiple launchers on the same ship, the AI only sees each one individually. So now the multiplier is = [ (# of missiles/craft)*(individual missile/craft damage)^2 ]/[ (# of weapons)*(individual weapon damage)^2 ]
Update (6674025):
  • The AI now always moves ships with boarding modules/assault shuttles/transporters last.
  • The AI attempts to estimate the survival rate of it's missiles vs PD and overcommits missiles to targets accordingly, instead of using a hardcoded overcommit multiplier.
  • The AI will not enter "stand off and bombard" mode if it's estimated missile/bomber survival rate is 0.
zolobolo
Posts: 1544
Joined: Fri Nov 25, 2016 3:49 pm

Re: Tactical Combat AI Mod

Post by zolobolo »

Transport with Assault Shuttles does not yet move last. Using version: 96b6618

Save link: https://www.dropbox.com/s/34d7fa9rctzud ... 4.rar?dl=0

In the above case, the attackers ignore the planet and concentrate on the carrier first - this is working well now
There seems to be something up with PD reservation here as after the initial 2 Turns, the assault fighters do not seem to take damage

Rotation of the Carrier still soaks up the damage output of the attackers even with lower recharge rate
Would it make sense to include the envelop modifier effect for energy base weapons or is that too much of a meddling in weapons configs?

Also noted something strange when trying to run the changes through the original test case: the AI attackers did not initiate the invasion against the carrier and the planet this time around which raises the question: doe the strategic AI somehow use the tactical AI to calculate the rough result of the engagement and hence desired to wait longer? I thought the strategic AI does not do that, else it wouldn't initiate so many invasions against fortresses where it looses all ships and does not stand a chance to win
Attachments
Transport not last.png
Transport not last.png (627.04 KiB) Viewed 13133 times
Post Reply