Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.97a is out! (02/02/24); New blog post: New music for Galatia Academy (06/12/24)

Author Topic: Teaching the AI about 'fleet power density'  (Read 1074 times)

intrinsic_parity

  • Admiral
  • *****
  • Posts: 3080
    • View Profile
Teaching the AI about 'fleet power density'
« on: April 20, 2022, 12:42:16 PM »

In my opinion, a significant portion of the common complaints about the AI stem from the AI failing to consider the broader context of combat. Issues with chasing, small ships 'getting in the way' in big battles, ships getting caught out of position or overextending, lack of aggression in clearly winning situations etc. all are potentially examples of this. I think that giving the AI some information about the 'density' of fleet power in combat could be a way to incorporate information about the broader context of battle into the AI's decision making process.

Abstractly, density is a measure of 'quantity' per unit of 'space'. For instance the term very frequently refers to 'mass per unit volume'. In this case, we're talking about trying to understand how much 'combat power' is in a certain area of battle. More specifically, that could mean 'how much enemy and friendly DP is near a certain point'. Lots of ships/DP in a small area = high density, few ships in a large area = low density.

Actually taking a density measure and producing some useful decisions/actions for the AI is the challenge. I don't necessarily have a definite idea about how this should be implemented, I just think that's the sort of information that a human uses when analyzing the battlefield to identify where ships should be. Density allows for identification of things like isolated ships, or the 'main enemy force' or the 'closest significant engagement'. Computing both enemy and friendly combat power density and comparing them also allows for identification of regions where one side is outnumbered/outgunned allowing for more intelligent attempts to assist allies, or exploit enemy vulnerability. It also gives the AI some ability to predict how an engagement will go without actually engaging. Often times, I think the AI is too reactive because it bases decisions on current flux levels, and sometimes by the time the flux levels reveal that the situation is bad, it is too late to do anything about it. I think these concepts could also be used to differentiate AI aggressions levels in an interesting way.

DP or FP can be used as a proxy for 'combat power'. You could definitely do more complicated/detailed analysis to get a better representation of 'combat power' at a specific point, but I'm not sure if that's necessary.

One suggestion for a simple implementation would be some sort of DP/FP weighted clustering of ship locations that is computed for the entire fleet/combat scenario periodically. Then individual ships can have access to that information whenever they make decisions. Personally I think clustering is elegant because it analyzes the entire space at once and identifies points of interest (cluster centers) automatically.

You can also do something like dividing the space into a grid and computing the combat power at each grid element, but that could potentially create performance issues depending on how fine the grid is, and you also need to figure out what regions of the grid are relevant to any particular decision. It does potentially give ships a clearer picture of their situation though.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24408
    • View Profile
Re: Teaching the AI about 'fleet power density'
« Reply #1 on: April 20, 2022, 01:06:31 PM »

This is interesting - and, something I've actually given quite a bit of thought a while back. One problem IMO is that this is a fundamentally abstract measure that - intentionally! - loses most of the details.

When you have the AI make decisions based on information like that, it's bound to get things badly wrong in terms of specifics; you'd end up with "why isn't it engaging" and instead of the answer being a relatively clear "flux is too high or it would be flanked if it did" it would instead be "the invisible density heuristic tripped a threshold because a fighter wing or a frigate 3000 units away moved fractionally closer".

Incidentally, in 0.95a the AI had a behavior where larger ships would try to group up and avoid getting sidetracked by enemy frigates. The end result of this was a bunch of confusion over the AI "refusing to engage". Ultimately, I think those decisions should be left to the player. You can slap a Defend on a larger ship and that should stop other ships from wandering off, etc etc. The AI trying to be too smart about strategic decisions like that is just going to be confusing - much of the time it's not going to do what the player wanted or expected - *even if it's actually the right thing to do* - but more importantly, it'll be much harder to figure out why.

(I think for humans this type of "density" is a first-order heuristic - how we narrow down the field of possibilities to look at things in detail before making actual decisions. It's not generally something we'll base the *actual* decisions on. It's a really neat thing to think about, though - how we make decisions/process information, how that might translate to AI! It's genuinely a fascinating topic.)
Logged

intrinsic_parity

  • Admiral
  • *****
  • Posts: 3080
    • View Profile
Re: Teaching the AI about 'fleet power density'
« Reply #2 on: April 20, 2022, 04:00:19 PM »

I think there are two different types of issues I was kinda addressing at the same time here. One is making decisions about immediate engagements, and the other is making a 'long term plan'. Some problems, like overextension, and cautiousness in overwhelmingly one sided situations, are issues about immediate engagements. Some problems like chasing down frigates, or deciding to help allies, are more about coming up with a 'plan'.

In terms of immediate engagements:
(I think for humans this type of "density" is a first-order heuristic - how we narrow down the field of possibilities to look at things in detail before making actual decisions.
I don't know if I agree with that. It seems to me like the player does make decisions like 'There are too many enemies near me, I need to back off', or 'there are lots of allies around, I can send it' directly from their assessment of fleet density. I think the best example where the current AI falls short is a frigate near a radiant. The AI frigate has no idea it is in danger until it dies instantly to the radiant, but the player knows that they are in danger before the radiant actually shoots and backs off to avoid that situation.

I'm definitely not suggesting to replace any of the current AI decision making processes (which are definitely valuable), just add an additional factor to them.

When you have the AI make decisions based on information like that, it's bound to get things badly wrong in terms of specifics; you'd end up with "why isn't it engaging" and instead of the answer being a relatively clear "flux is too high or it would be flanked if it did" it would instead be "the invisible density heuristic tripped a threshold because a fighter wing or a frigate 3000 units away moved fractionally closer".
I think the sensitivity to small movements of ships shouldn't be such a large issue, i.e. if one fighter wing moving closer is enough to move you over a threshold, you were already right on the edge of needing to back off, so it shouldn't seem unreasonable. I feel like 'it backed off because there were too many enemies close by relative to the amount of friendlies' is a pretty intuitive explanation, very similar to 'I was getting flanked' IMO. I can definitely understand that the details of implementation could get messy though. It just seems clear to me that this is the sort of information the player uses to make decisions that the AI currently is not good at.

In terms of long term plans:
Incidentally, in 0.95a the AI had a behavior where larger ships would try to group up and avoid getting sidetracked by enemy frigates. The end result of this was a bunch of confusion over the AI "refusing to engage".
I think this not working is sort of getting at the problem. The issue isn't really about 'sticking together', or even proximity to specific ships, it's about the AI not having any plan for what it should be doing. Of course the player can make those plans, but I feel like it could be valuable for the AI to have a decent plan on its own. That seems to be inline with a lot of other design decisions that lead towards the player being able to just pilot their ship if they want.

In terms of existing game mechanics, I think what the player wants is the AI to assign itself an engage order on a 'relevant' enemy ship. The problem is that 1: engage orders kinda don't work very well (I find I need to assign and cancel eliminate orders to get the behavior I expect from and engage order), and 2: the AI doesn't know what 'relevant' means and that's where the fleet density idea comes into play. I think this sort of logic already exists in the game in the system that automatically distributes ships between capture/defend orders.

The clustering idea is a way to dynamically identify points of interest without the player needing to give a ton of orders like they do now. I feel like giving defend orders on ships is running into the same problem that the 'stick together' solution to chasing frigates did. The player doesn't really want their ships to stick together (although that might be the result sometimes), they want their fleet to be distributed well to engage the enemy, and they have to be juggling orders to keep up with the dynamically changing enemy positions which could be described as 'babysitting' or possibly 'herding cats'. It would be nice if the AI had at least a basic understanding of where it would be valuable to go, and the player can work from there.
« Last Edit: April 20, 2022, 04:05:11 PM by intrinsic_parity »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24408
    • View Profile
Re: Teaching the AI about 'fleet power density'
« Reply #3 on: April 20, 2022, 04:36:36 PM »

I don't know if I agree with that. It seems to me like the player does make decisions like 'There are too many enemies near me, I need to back off', or 'there are lots of allies around, I can send it' directly from their assessment of fleet density. I think the best example where the current AI falls short is a frigate near a radiant. The AI frigate has no idea it is in danger until it dies instantly to the radiant, but the player knows that they are in danger before the radiant actually shoots and backs off to avoid that situation.

I know exactly what you mean, yeah. The problem is that with the "density" idea - for this kind of thing, anyway - the information that "this is a Radiant" is completely lost. It'd do the same thing for, I don't know, a couple of Eagles or whatever was enough to trip that kind of threshold. It's not the density that's the danger, it's a few highly specific things about the Radiant. Or e.g. a Tachyon Lance Paragon, etc.


I think the sensitivity to small movements of ships shouldn't be such a large issue, i.e. if one fighter wing moving closer is enough to move you over a threshold, you were already right on the edge of needing to back off, so it shouldn't seem unreasonable.

Not necessarily - it'd be on the edge of the threshold, not on the edge of actually needing to back off. It could well be a bunch of slow low-range ships that aren't a threat and your faster, longer-ranged ship would never engage them because their density is too high. My point is that if you don't look at details, and make tactical decisions based on that kind of abstracted data, it will go bad real quick.

The clustering idea is a way to dynamically identify points of interest without the player needing to give a ton of orders like they do now. I feel like giving defend orders on ships is running into the same problem that the 'stick together' solution to chasing frigates did. The player doesn't really want their ships to stick together (although that might be the result sometimes), they want their fleet to be distributed well to engage the enemy, and they have to be juggling orders to keep up with the dynamically changing enemy positions which could be described as 'babysitting' or possibly 'herding cats'. It would be nice if the AI had at least a basic understanding of where it would be valuable to go, and the player can work from there.

Well, the problem with the "stick together" solution was the player not being aware of what was going on, so the "defend" order does go around that! (Cases of someone not realizing what "defend" does notwithstanding...)

But yeah, hmm. I mean, I can see what you're getting at - basically dynamic, invisible "defend" orders based on this kind of density evaluation or whatever. I can see the appeal, though I also feel like it would have the same problems as the "stick together" code. And being able to put "defend" on a ship rather than a point reduces the amount of juggling you need to do while still allowing your ships to spread out enough to engage well; that was one of the reasons for that addition.

Still, bears more thinking about! I appreciate the suggestion.
Logged

intrinsic_parity

  • Admiral
  • *****
  • Posts: 3080
    • View Profile
Re: Teaching the AI about 'fleet power density'
« Reply #4 on: April 20, 2022, 08:49:56 PM »

I know exactly what you mean, yeah. The problem is that with the "density" idea - for this kind of thing, anyway - the information that "this is a Radiant" is completely lost. It'd do the same thing for, I don't know, a couple of Eagles or whatever was enough to trip that kind of threshold. It's not the density that's the danger, it's a few highly specific things about the Radiant. Or e.g. a Tachyon Lance Paragon, etc.
Perhaps that's an indication that radiants are still under-costed DP wise :P, but I get what you are saying. My instinct is to just make a more complex measure of fleet power to capture more details (something along the lines of checking how much enemy DPS is in range), but I realize that may not be super practical.

Well, the problem with the "stick together" solution was the player not being aware of what was going on, so the "defend" order does go around that! (Cases of someone not realizing what "defend" does notwithstanding...)

But yeah, hmm. I mean, I can see what you're getting at - basically dynamic, invisible "defend" orders based on this kind of density evaluation or whatever. I can see the appeal, though I also feel like it would have the same problems as the "stick together" code. And being able to put "defend" on a ship rather than a point reduces the amount of juggling you need to do while still allowing your ships to spread out enough to engage well; that was one of the reasons for that addition.
Yeah, I just would like the baseline behavior to be a bit more reliable so I don't need to spend so much effort just to make sure the AI isn't doing dumb stuff.


Just another few suggestions kind of tacked on since I don't feel like making a new thread:

I would like a version of the defend order where ships are not dynamically allocated to it. Sometimes I want a specific group of ships to stick together always, and I don't want other ships to reassigned to that group. For example, I find that groups of frigates function very well together (I don't want them to escort, just fight the same targets generally), but I really don't want big slow ships getting assigned since they can't keep up. I can manually assign every ship to a 'defend' level order so that they don't get re-assigned, but that's very tedious.

It would be nice if search and destroy was persistent through manually assigned orders e.g. the ship returns to search and destroy after if finishes a manually assigned order like capturing a flag or eliminating a ship.
Logged

DirectionsToL3Please

  • Commander
  • ***
  • Posts: 100
    • View Profile
Re: Teaching the AI about 'fleet power density'
« Reply #5 on: April 21, 2022, 12:50:14 PM »

I still feel like almost all of these problems are rooted in the AIs inability to move well in the battle space.  I've brought it up a time or two but either I'm not describing it well or nobody agrees with me, since there's no dialog on it.  But I still think it boils down to the AI just never manages to be in the right place, so a thorough inability to do anything right logically follows.

Your power density idea is generally a lot like what I thought would help - setting up the idea of the core of the fleet, and teaching the AI to prefer to move toward that core unless it has other explicit player-issued orders - but it has some finer detail baked in.
Logged

Delta_of_Isaire

  • Lieutenant
  • **
  • Posts: 65
    • View Profile
Re: Teaching the AI about 'fleet power density'
« Reply #6 on: April 27, 2022, 05:25:03 AM »

(Just for the record - I have extensive thoughts on this topic but I cannot fully articulate my opinion yet. There is definitely *something* wrong with current AI positioning, caused by poor default behavior and/or poor response to orders. But I need to study the AI's response to orders a bit more. Going to do a command playthrough now to do that, with no manual piloting, and see how that compares to my usual approach.)
Logged