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: Simulator Enhancements (03/13/24)

Author Topic: AI range management  (Read 3523 times)

TaLaR

  • Admiral
  • *****
  • Posts: 2794
    • View Profile
AI range management
« on: March 09, 2019, 12:08:36 AM »

2 Hammerhead variants, long ranged (LR) and short ranged (SR). Both are very straightforward, no missiles or any difficult tactics requirements. They just need to maintain correct range to win.
Spoiler


[close]

As long as range is above Needler range of 800*1.2 LR ship wins, under Railgun range of 700*1.2(-extra for weapon placement on ship) SR ship wins. In between is somewhat unstable and depends on armor/hull/flux state, but overall SR ship somewhat wins at this range.

Both have same speed, meaning that as long as LR ship is serious about maintaining range and SR ship doesn't try to sacrifice armor for zero flux boost (AI doesn't do this), closing the distance is near impossible. Which is exactly how this plays with LR ship under player control - one-sided win for LR ship.
Getting win is also easy with player-piloted SR ship, LR ship just let's you close distance and loses after few offensive vents.

Under AI control LR ship keep committing mistakes until it dies.
- It doesn't seem to take inertia into account during approach. So while it starts trying to backpedal once in combat range, that's too late. It needs to enter combat range at near 0 relative speed.
=> which leads to ships closing at least into Needler range and at worst straight into Railguns, and both ships getting to high flux.
- LR ship allows the other side to get away when both are at high flux, but only CR ship is actually threatened (due to range). LR ship can recover flux by combination of passive dissipation, intermittent hold fire and shield-flicker (against mauler), without giving opponent opportunities to vent.

SR ships has it's own problems too:
- It doesn't try to close distance hard enough. It often is happy with Needler range, despite Railgun range being so much more advantageous (since it accumulates some flux in process of closing range).
- SR ship allows to break contact after reaching Railgun range. Unless SR ship has already lost too much armor/hull and/or has much higher current flux than LR ship, it can armor tank/offensive vent to victory.

Overall "low flux = let's approach, high flux = let's retreat and vent" is very flawed logic. Ships need to be aware in which range-bands they can win against an opponent and do their best to maintain/close the distance (taking inertia into account).
- It's ok to to not use vent opportunity and keep firing instead (when you have range and speed advantage).
- It's also ok to offensive vent/armor tank in close range if closing the distance again would cost you more and you have massive advantage in close combat.
- There is no need to close distance against enemy that is slower (system effects included) and has short range firepower advantage. This just plays into their hand.
- Situation where ship A wins against ship B at medium range, but (slowly) loses at long range and (quickly) loses at short range is also possible.
- AI should probably consider armor-tanking zero flux boost as valid way to close the distance. Which can be countered by hold fire + back off (if there are allies to retreat to).
Logged

Goumindong

  • Admiral
  • *****
  • Posts: 1889
    • View Profile
Re: AI range management
« Reply #1 on: March 09, 2019, 09:46:24 AM »

What does the logic tree or weighted decision algorithm youre proposing look like?
Logged

TaLaR

  • Admiral
  • *****
  • Posts: 2794
    • View Profile
Re: AI range management
« Reply #2 on: March 09, 2019, 10:29:10 AM »

I don't pretend to have implementation-ready algorithm.

Most bruteforce approach would be to simulate battles at all different range bands per ship pairing. Simulation can be simplified, but this would also make it less accurate. Minimum would be straight fire exchange till one side drops dead, no venting, damage affecting abilities used on cooldown, approach phase included (to account for range advantage one side may have).
Then try to avoid range bands optimal for enemy and maintain ones beneficial to self by some score metric (combining time spent + hull/armor left + missiles left etc from simplified simulation). All simulations (each ship on one side vs each on the other) can be done while combat is loading, leaving only scores to operate on during combat.
Logged

Goumindong

  • Admiral
  • *****
  • Posts: 1889
    • View Profile
Re: AI range management
« Reply #3 on: March 09, 2019, 11:08:26 AM »

My point wasnt “you need to know what the end result is” my point was that the implementation is not so simple, especially with multiple ships on both sides and limited ability to define actions
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23988
    • View Profile
Re: AI range management
« Reply #4 on: March 09, 2019, 11:09:26 AM »

Just a couple of assorted thoughts!

- There are lots of factors that would be difficult to... factor in - ship systems that increase/decrease damage or weapon range or deal damage or change the damage dealt to the enemy ship or disable it in some way or ion weapons etc etc. I think this is basically impossible - we can come up with some ship combinations where it's simpler, but not in any general sense.
- An AI that's capable of reliably maintaining narrow range bands feels robotic (despite the player being able to do this - different standards, argh!) and is much more frustrating to fight against.
- Combining the prior two points: if narrow range bands are maintained to that degree, an error in calculating them results in consistently bad behavior that's glaring in its robotic-ness. (As opposed to, say, sliding in too close from what looks inertia (though I'm fairly sure it isn't), which feels somewhat more natural, and also allows for more variety in weapon use/outcomes. Even if they aren't always positive.)
- This is mostly applicable in 1-1s. These are easiest to test and have some importance, but as soon as you get into fleet-vs-fleet combat, the "less flux good, more flux bad" logic has a better chance of being correct.


(That said, a bit back I made a few tweaks that should generally make it slightly better at not getting too close...)
Logged

TaLaR

  • Admiral
  • *****
  • Posts: 2794
    • View Profile
Re: AI range management
« Reply #5 on: March 09, 2019, 12:44:34 PM »

- There are lots of factors that would be difficult to... factor in - ship systems that increase/decrease damage or weapon range or deal damage or change the damage dealt to the enemy ship or disable it in some way or ion weapons etc etc. I think this is basically impossible - we can come up with some ship combinations where it's simpler, but not in any general sense.
- An AI that's capable of reliably maintaining narrow range bands feels robotic (despite the player being able to do this - different standards, argh!) and is much more frustrating to fight against.
- Combining the prior two points: if narrow range bands are maintained to that degree, an error in calculating them results in consistently bad behavior that's glaring in its robotic-ness. (As opposed to, say, sliding in too close from what looks inertia (though I'm fairly sure it isn't), which feels somewhat more natural, and also allows for more variety in weapon use/outcomes. Even if they aren't always positive.)
- This is mostly applicable in 1-1s. These are easiest to test and have some importance, but as soon as you get into fleet-vs-fleet combat, the "less flux good, more flux bad" logic has a better chance of being correct.

-1) Yes, I agree that accurate range band estimation is difficult. As player I just know them, because I've tried similar scenarios before.

-2) Player executing practiced optimal strategy would look quite robotic too (near perfect range management, shield flicker, mini-venting, skim-dodging, etc). I don't think it's too much of a problem as long as it doesn't rely on superhuman reflexes too much and executed strategy is at least semi-correct.

-3) It already happens in some cases, the obvious one being Aurora. It sometimes activates ship system to stay at fixed wrong distance (too far to fire it's weapons, too close to avoid mine). I still think inertia=not taking relative speed into account is part of problem, since adding Auxiliary Thrusters for better acceleration somewhat helps.

-4) Then how about curbing at least worst cases of "less flux good, more flux bad" strategy.
- Instant death via 4xTL Paragon (idly approaching ships with overwhelming near instant firepower leads to death before "less flux good, more flux bad" logic has chance to work).
- Slower(or equal speed) and shorter-ranged ships are doomed with current logic. The only question is how long they survive. Reckless/Aggressive AI could try to close distance via zero flux boost/ship system. Gets ridiculous when sim Onslaught gets slowly disassembled by Conquest with 2 Gauss Guns as the only weapons and half OP unused.
Spoiler
[close]
- Very often AI ruins perfectly good attempt at victory near-obtained at long range by retreating to vent. Equal or higher speed + enemy vent time at current flux levels is higher or equal to mine + enemy has no movement ship system + missiles can't reach me during vent = can vent right outside their firing range.

Logged

intrinsic_parity

  • Admiral
  • *****
  • Posts: 3071
    • View Profile
Re: AI range management
« Reply #6 on: March 09, 2019, 01:27:56 PM »

Can someone explain the way the AI chooses what range it wants to be at in the current game?
Logged

Goumindong

  • Admiral
  • *****
  • Posts: 1889
    • View Profile
Re: AI range management
« Reply #7 on: March 09, 2019, 02:26:12 PM »

Iirc it chooses an optimal range band based on the officer and weapons loadout. The optimal range band is slightly inside the range of its shortest weapons for reckless/aggressive. And just under the edge of its longest weapons for cautious. And just under the edge of its average for steady. Weapons flagged with PD are ignored. Timid avoids combat all together based on opponents range and ignores the range of its weapons. Civilian ships default to timid behavior.

PD flagged weapons are ignored for this estimation when the ship has non-PD flagged weapons fit.

The other factors are the threat of opponents weapons, the current target, and the flux level. Aggressive officers have a lowered modifier for threat of their targets weapons and reckless officers ignore the threat from any ship that is not its target.
Logged

Thaago

  • Global Moderator
  • Admiral
  • *****
  • Posts: 7174
  • Harpoon Affectionado
    • View Profile
Re: AI range management
« Reply #8 on: March 09, 2019, 02:36:28 PM »

[Side note: could you crop your images please, especially for loadout pics where 90% is background? I don't care for file size, but if I actually want to look at them I need to zoom the page way out, at which point I can't read your text at all and can barely make out the text in the images themselves! ]

It would be nice for the AI to manage its range bands better, and this test shows the issues in a nice and controlled way thats good for bugfinding, but its still a very artificial test.

In most real gameplay you either locally outnumber the enemy: you want your allied ships to close in and fire at maximum firepower to kill the target, backing off when they individually need to. Or you are outnumbered: what target to consider for range bands becomes ambiguous and picking the wrong thing could very easily lead to a ship getting popped.

So while I think you've found some things that need to be shored up, I don't think the idea of finding the perfect range and sticking to it for an individual (and how would that even be done in complex situations?) is practical or the best path.
Logged

From a Faster Time

  • Commander
  • ***
  • Posts: 146
    • View Profile
Re: AI range management
« Reply #9 on: March 10, 2019, 04:22:55 AM »

- It doesn't seem to take inertia into account during approach. So while it starts trying to backpedal once in combat range, that's too late. It needs to enter combat range at near 0 relative speed.
Funny, I brought up exactly that as a problem to Alex a while ago.
I don't suppose Alex could add something like "optimal range" value in the ships loadout screen. That a player could set for a specific ship and it's loadout, that the AI will try to use over it's default range preferences....Would certainly take out of some of the complexity in AI figuring out what the optimal range is and all it would have to do is try to maintain it.
Logged