Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.98a is out! (03/27/25)

Pages: [1] 2

Author Topic: AI controlled ships switch targets too often  (Read 1830 times)

Genir

  • Captain
  • ****
  • Posts: 346
    • View Profile
AI controlled ships switch targets too often
« on: June 27, 2023, 05:01:09 PM »

The issue:

The issue we're encountering involves AI-controlled ships struggling to maintain a focus on their target when multiple adversaries are present. This problem becomes apparent when the AI prematurely switches its offensive focus from one enemy to another, even when the initial target is nearly destroyed (with just a few percentage points of hull integrity remaining and no shields). This switching occurs despite the fact that the original target remains well within the ship's engagement range.

Steps to reproduce:

Run the attached savefile, Run Simulation using one of the Executors (I used the one with Aggresive officer). As enemies chose all available Hammerheads and Falcons (7 ships in total). The Executor should:
  • drop targets still within range
  • attempt to drop target, rotate by a small degree, and return to target
  • wobble undecidely when switching targets and presented with multiple close opportunities
  • switch to targets that are at a considerable angular distance, even when other targets are available within range at much closer angular distance

Savefile
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 25822
    • View Profile
Re: AI controlled ships switch targets too often
« Reply #1 on: June 27, 2023, 05:17:11 PM »

(Moved this to suggestions, as this isn't a bug.)

Basically, the AI tries to move in a way that prevents it from being flanked. Chasing after kills is an extremely slippery slope and it's quite hard to tell when it's too risky, so it mainly just doesn't do this at all.
Logged

Genir

  • Captain
  • ****
  • Posts: 346
    • View Profile
Re: AI controlled ships switch targets too often
« Reply #2 on: June 28, 2023, 04:38:04 PM »

Thank you for the reply.

Please, don't misunderstand me. I'm not talking about chasing ship, but about situations when the AI controlled ship switches between multiple targets that are in range and don't need to be chased. Sometimes switching back and forth.

Further, the issue is not necessarily related to finishing damaged opponents, but simply to the ability to effectively combat a selected target, even if it's high health. Dropping a successfully engaged target (that is often right in front of the ship), and switching to a fresh one is very dissatysfying, double so if the engaged target is close to death. Also, moving to avoid flanking does't imply the ship needs to change targets when the previous target is still within range.

To sum it up, the issue is related to the selection of targets from the pool of enemies within range, not the ai-controlled ship movement.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 25822
    • View Profile
Re: AI controlled ships switch targets too often
« Reply #3 on: June 28, 2023, 04:58:01 PM »

I understand what you're saying, yes! However, target selection for the AI *is* related to movement; it picks a target ship and moves/turns in relation to it, and what target it picks heavily depends on its desired movement pattern.

The case where a large ship is fighting a lot of smaller ones is kind of a lost cause anyway, right? At least, the situation you described in the OP feels like one without any great options, just some less-bad ones.
Logged

Genir

  • Captain
  • ****
  • Posts: 346
    • View Profile
Re: AI controlled ships switch targets too often
« Reply #4 on: June 28, 2023, 05:41:17 PM »

The situation in the OP was chosen specifically to recreate the most severe case of the issue, for easy debugging. However, the problem does manifests itself with just two possible targets.

I'm fully aware the behavior may be the result of AI intricacies and difficult or even impossible to fix. But I'm certain the thing is indeed an issue. I keep seeing it mentioned in Discord discussions repeatedly.

I'll try to provide video examples, but I'll probably take me several days.

Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 25822
    • View Profile
Re: AI controlled ships switch targets too often
« Reply #5 on: June 28, 2023, 05:43:43 PM »

I appreciate it, but no need, I think! I'm fairly sure I know exactly what you're describing. It's just one of those things where, given how things work, a "solution" is likely to cause more problems than the initial problem.
Logged

Sendrien

  • Captain
  • ****
  • Posts: 319
    • View Profile
Re: AI controlled ships switch targets too often
« Reply #6 on: June 29, 2023, 08:10:58 AM »

As someone who observes AI extremely closely, I can say that the target switching is not always the optimal survival behaviour.

In fact, take a (practically) stationary Paragon with 4 Tachyon Lances surrounded by many (10+) small frigates. Players intuitively know that the optimal strategy is to focus down one frigate at a time with an alpha strike of all 4 lances, resulting in an immediate kill and an immediate lowering of the flux damage output to the Paragon's shields.

The AI will not do this. It will change targets frequently, warding away the enemies surrounding it, and end up being exposed to enemy fire from multiple directions for a much longer period (unnecessarily).
Logged

TaLaR

  • Admiral
  • *****
  • Posts: 2895
    • View Profile
Re: AI controlled ships switch targets too often
« Reply #7 on: June 29, 2023, 12:14:07 PM »

Well, it's not a good idea to split soft flux weapons between multiple targets (or switch too often) in general. Though 4TL Paragon vs frigates is the most extreme case of this.
Logged

itBeABruhMoment

  • Commander
  • ***
  • Posts: 175
    • View Profile
Re: AI controlled ships switch targets too often
« Reply #8 on: June 30, 2023, 09:05:52 AM »

I'm going to have to agree that the ai constantly retargeting is a problem. From experience, even ships with turrets have trouble aiming when turning to face another target, so while a ship is retargeting it more or less can't shoot. Not shooting is the last thing you want to do when multiple enemies are approaching, and consistently retargeting makes a ship spend large portions of time not shooting.
Logged

Lawrence Master-blaster

  • Admiral
  • *****
  • Posts: 1091
    • View Profile
Re: AI controlled ships switch targets too often
« Reply #9 on: June 30, 2023, 09:53:18 AM »

The AI definitely switches targets too often and it is a problem, but I don't think it's one that can be solved. There's only so much you can do with AI.

You could try to mitigate it with ships themselves, for example by widening the hardpoint weapon arc to 45 degrees or something.
Logged

Genir

  • Captain
  • ****
  • Posts: 346
    • View Profile
Re: AI controlled ships switch targets too often
« Reply #10 on: June 30, 2023, 06:16:36 PM »

Quote
The AI definitely switches targets too often and it is a problem, but I don't think it's one that can be solved.

But it wasn't a problem in version 0.95, at least not noticeable. So the AI can definitely be designed to keep its target. It's a matter of trade-offs probably.
Logged

Lawrence Master-blaster

  • Admiral
  • *****
  • Posts: 1091
    • View Profile
Re: AI controlled ships switch targets too often
« Reply #11 on: June 30, 2023, 08:46:54 PM »

It definitely was a problem in last version. Maybe you're now using ships that suffer more from it(i.e. ones with hardpoints)
Logged

Genir

  • Captain
  • ****
  • Posts: 346
    • View Profile
Re: AI controlled ships switch targets too often
« Reply #12 on: July 01, 2023, 05:40:43 AM »

Quote
It definitely was a problem in last version. Maybe you're now using ships that suffer more from it(i.e. ones with hardpoints)

That's true to an extent. However, i'm not basing my statements on my observations alone. I see the problem of target changing being severe this patch mentioned in Discord.
Logged

Genir

  • Captain
  • ****
  • Posts: 346
    • View Profile
Re: AI controlled ships switch targets too often
« Reply #13 on: July 11, 2023, 04:25:17 PM »

Quote
Basically, the AI tries to move in a way that prevents it from being flanked.

I went through the battle several more times. From my observation the ship does not try to evade flanking, but simply engages the closest target. In fact, the behavior of attacking the closest target is quite evident. When the current target retreats to a distance greater than any other ship, the Executor immediately starts to turn to the now-closest ship. Even if it has to turn 180 degree and ignore several other in-range ships, over which it sweept its targeting arcs. In case of two enemies hovering at about equal distance, this can even lead to the Executor wobbling undecidedly between the two.
Logged

Genir

  • Captain
  • ****
  • Posts: 346
    • View Profile
Re: AI controlled ships switch targets too often
« Reply #14 on: April 19, 2024, 08:33:50 AM »

As a reference I post a pair of videos: https://imgur.com/a/wVUjMbR.

First shows a Nova controlled by vanilla AI (with nova drive disabled) exhibiting an extreme case of target switching. Avoiding being flanked leads to its demise.

Second shows the same Nova controlled by AI I'm modding currently. Notice it doesn't chase enemies, but at the same time is determined to destroy them.
Logged
Pages: [1] 2