Why do AI-Controlled ship turn so very slowly?

This forum is the ideal place for all discussion relating to X4. You will also find additional information from developers here.

Moderator: Moderators for English X Forum

Post Reply
Scoob
Posts: 10622
Joined: Thu, 27. Feb 03, 22:28
x4

Why do AI-Controlled ship turn so very slowly?

Post by Scoob »

Hey all,

This is far from a new thing, going back to prior X games, but it is exceptionally annoying at times.

I just had a recent example of this, leading to a needless ship death. I'd ordered a ship to explore through a Gate, it entered the System and.. XENON! Ok, no problem, just turn around and leave - thus ordered - and the super-nimble Rapier which can readily flip a 180 in under a second in player's hands took TWELVE SECONDS to turn around. Twelve. That's over ten times more slowly than it can actually turn. Why? Xenon ships that were around 15 or so km away, were easily able to close and destroy the Rapier before it had completed its turn. In player hands, I could have completed that turn in a second, and been zooming away in travel mode a couple of seconds after that.

This can be observed in all ships when under AI control. When I take manual control of my Raptor for example, it feels positively nimble compared to how it turns under AI control. However, with S and M-Class ships, well, their ability to turn quickly of often key to their effectiveness. Be it quickly getting on-vector for a target, or turning to evade etc. However, they turn at, I'd guestimate, typically at HALF their actual capability. Why?

I really don't understand this. It seems silly to lose a ship that can effortlessly flip on a dime and zip out of there, never under any legitimate threat in a player's hands. Yet under AI control - and OOS to boot - it took twelve seconds to turn 180 degrees.

This must be something coded into the AI. A ship, with a given load-out, has its absolute abilities, but the AI does not use them. Does anyone know why this is? Is it to give the Player some advantage when flying a ship themselves? We don't need this advantage, we have others.
User avatar
stooper88
Posts: 222
Joined: Sat, 7. Jul 07, 02:48
x4

Re: Why do AI-Controlled ship turn so very slowly?

Post by stooper88 »

I forget the original source I learned it from, but my understanding is that all AI behaviors will be woefully slow compared to any player because the game is deliberately conserving CPU processing power. In essence, they know how to make the AI pilots much smarter, but doing so would need to be applied to EVERY pilot at EVERY moment of the game and would greatly impact the engine performance and hardware requirements. So the less-than-perfect AI decision making speed is a trade-off in order to sustain playability.
Beware the pirate spacesuit patrols!
Raptor34
Posts: 2650
Joined: Sat, 12. Jun 10, 04:43
x4

Re: Why do AI-Controlled ship turn so very slowly?

Post by Raptor34 »

stooper88 wrote: Thu, 28. Nov 24, 22:53 I forget the original source I learned it from, but my understanding is that all AI behaviors will be woefully slow compared to any player because the game is deliberately conserving CPU processing power. In essence, they know how to make the AI pilots much smarter, but doing so would need to be applied to EVERY pilot at EVERY moment of the game and would greatly impact the engine performance and hardware requirements. So the less-than-perfect AI decision making speed is a trade-off in order to sustain playability.
While I wouldn't be surprised. This is something we saw first hand with the MARS mod from back in X3 after all. I would be interested in a source for it.
User avatar
stooper88
Posts: 222
Joined: Sat, 7. Jul 07, 02:48
x4

Re: Why do AI-Controlled ship turn so very slowly?

Post by stooper88 »

Raptor34 wrote: Thu, 28. Nov 24, 22:55 While I wouldn't be surprised. This is something we saw first hand with the MARS mod from back in X3 after all. I would be interested in a source for it.
Found my source: Captain Snuggles - X4 Oversimplified: Understanding the AI, more specifically the imperfect simulation portion.

As a developer, it makes sense to me. AI pilots can make swifter decisions if their decision trees take more factors into consideration and provide more branches to consider and potentially execute. But all of that would come at the expense of greater overhead for every instance of an AI pilot. So in order to streamline the gameplay, each tree has to be reduced into the smallest set of primitive actions that can be taken, which in turn can cumulatively be combined to simulate more complex behaviors. Unfortunately, but unavoidably, the consequence is that a single complex decision (observe the threatening Xenon and immediately flee) becomes a prolonged series of multiple simplified decisions culminating in a 12 second delay before retreating.
Beware the pirate spacesuit patrols!
Raptor34
Posts: 2650
Joined: Sat, 12. Jun 10, 04:43
x4

Re: Why do AI-Controlled ship turn so very slowly?

Post by Raptor34 »

stooper88 wrote: Thu, 28. Nov 24, 23:40
Raptor34 wrote: Thu, 28. Nov 24, 22:55 While I wouldn't be surprised. This is something we saw first hand with the MARS mod from back in X3 after all. I would be interested in a source for it.
Found my source: Captain Snuggles - X4 Oversimplified: Understanding the AI, more specifically the imperfect simulation portion.

As a developer, it makes sense to me. AI pilots can make swifter decisions if their decision trees take more factors into consideration and provide more branches to consider and potentially execute. But all of that would come at the expense of greater overhead for every instance of an AI pilot. So in order to streamline the gameplay, each tree has to be reduced into the smallest set of primitive actions that can be taken, which in turn can cumulatively be combined to simulate more complex behaviors. Unfortunately, but unavoidably, the consequence is that a single complex decision (observe the threatening Xenon and immediately flee) becomes a prolonged series of multiple simplified decisions culminating in a 12 second delay before retreating.
But that's not what the OP is saying though, they said they manually ordered them to leave yet it still took a 12 second delay.
User avatar
stooper88
Posts: 222
Joined: Sat, 7. Jul 07, 02:48
x4

Re: Why do AI-Controlled ship turn so very slowly?

Post by stooper88 »

Raptor34 wrote: Thu, 28. Nov 24, 23:55 But that's not what the OP is saying though, they said they manually ordered them to leave yet it still took a 12 second delay.
Sorry you're right, the pilot didn't need to evaluate the threat, it just needed to reverse course. But nonetheless, the actual "flying" behavior constitutes endless series of "decisions" (check for command, check for current trajectory, check for collision, etc) as well as "skill checks" in accordance with the pilot skill. Any ship under AI control will be constantly undergoing these game engine mechanics. Consequently, Egosoft's implementation can result in these arduously long drawn out behaviors.
Beware the pirate spacesuit patrols!
flywlyx
Posts: 1203
Joined: Sat, 15. May 21, 03:45
x4

Re: Why do AI-Controlled ship turn so very slowly?

Post by flywlyx »

stooper88 wrote: Fri, 29. Nov 24, 00:02 Sorry you're right, the pilot didn't need to evaluate the threat, it just needed to reverse course. But nonetheless, the actual "flying" behavior constitutes endless series of "decisions" (check for command, check for current trajectory, check for collision, etc) as well as "skill checks" in accordance with the pilot skill. Any ship under AI control will be constantly undergoing these game engine mechanics. Consequently, Egosoft's implementation can result in these arduously long drawn out behaviors.
All these calculations waste resources. Instead of simply turning 180 degrees full speed and going full throttle, the system now has to compare pilot levels, determine the correct turn speed, apply that to the ship, check the pilot level again, verify acceleration limits, and apply those limits—all with manual "waits" in between. Each of these additional steps consumes additional resources.
User avatar
stooper88
Posts: 222
Joined: Sat, 7. Jul 07, 02:48
x4

Re: Why do AI-Controlled ship turn so very slowly?

Post by stooper88 »

flywlyx wrote: Fri, 29. Nov 24, 06:48 All these calculations waste resources. Instead of simply turning 180 degrees full speed and going full throttle, the system now has to compare pilot levels, determine the correct turn speed, apply that to the ship, check the pilot level again, verify acceleration limits, and apply those limits—all with manual "waits" in between. Each of these additional steps consumes additional resources.
I get it that the suboptimal AI piloting is frustrating. But it's not wasteful if it's the core of how the game works. Simply turning 180 degrees is not as straightforward as it seems when the system that has to do it must be generalized. Consider what happens if another ship has flown in from behind. The AI pilot has to know how to handle that possibility and countless others. The added pauses are a safety mechanism to prevent "stale" data from informing a bad decision. It's like how children are taught to look both ways, wait, and look again before crossing the street. It's common practice to include such buffers in software protocols when reliability must take precedence over speed. Ironically, this sometimes results in unreliable AI piloting. But in general, the system makes sense and is serving a valid purpose.
Beware the pirate spacesuit patrols!
flywlyx
Posts: 1203
Joined: Sat, 15. May 21, 03:45
x4

Re: Why do AI-Controlled ship turn so very slowly?

Post by flywlyx »

stooper88 wrote: Fri, 29. Nov 24, 14:49 I get it that the suboptimal AI piloting is frustrating. But it's not wasteful if it's the core of how the game works.
Could you explain why making pilots less efficient is fundamental to the game's design? As I mentioned earlier, the ideal solution is usually the most efficient one, and adding unnecessary calculations doesn't improve the system. Introducing unnecessary RNG during these processes just lowers overall efficiency. RTS games have been around for decades, with units consistently performing optimally, so it's hard to believe that subpar AI could be considered the core of how the game works.
stooper88 wrote: Fri, 29. Nov 24, 14:49 Simply turning 180 degrees is not as straightforward as it seems when the system that has to do it must be generalized. Consider what happens if another ship has flown in from behind. The AI pilot has to know how to handle that possibility and countless others.
Just push them aside if other ships are nearby. Yes, they might occasionally get stuck together, as seen in other games. However, Egosoft's current solution isn't any better, despite using significant computational resources to determine a "safe position."
stooper88 wrote: Fri, 29. Nov 24, 14:49 The added pauses are a safety mechanism to prevent "stale" data from informing a bad decision. It's like how children are taught to look both ways, wait, and look again before crossing the street. It's common practice to include such buffers in software protocols when reliability must take precedence over speed. Ironically, this sometimes results in unreliable AI piloting. But in general, the system makes sense and is serving a valid purpose.
I understand why the waits are in place, but why reduce the turning speed? How does it help if a ship takes 5 seconds to turn instead of 3?
gorgofdoom
Posts: 227
Joined: Wed, 5. Dec 18, 18:48
x4

Re: Why do AI-Controlled ship turn so very slowly?

Post by gorgofdoom »

flywlyx wrote: Fri, 29. Nov 24, 17:47
I understand why the waits are in place, but why reduce the turning speed? How does it help if a ship takes 5 seconds to turn instead of 3?
Why do pilots have differing skill levels at all?

I surmise it's to ensure one side will win in a reasonable amount of time. Even with a fight between two identical ships it is astronomically unlikely they will both have the exact same capabilities. One must have the advantage, or they may fight indefinitely, which does not really help the simulation as a whole.
flywlyx
Posts: 1203
Joined: Sat, 15. May 21, 03:45
x4

Re: Why do AI-Controlled ship turn so very slowly?

Post by flywlyx »

gorgofdoom wrote: Fri, 29. Nov 24, 22:10 Why do pilots have differing skill levels at all?

I surmise it's to ensure one side will win in a reasonable amount of time. Even with a fight between two identical ships it is astronomically unlikely they will both have the exact same capabilities. One must have the advantage, or they may fight indefinitely, which does not really help the simulation as a whole.
In X4, weapons significantly outperform defensive equipment, especially since boosting is linked to shields. This makes it highly unlikely for the weaker side to escape if the stronger side knows how to chase effectively.
If this is truly their concern, they shouldn't consider the boost change, as it will significantly extend combat duration.
User avatar
stooper88
Posts: 222
Joined: Sat, 7. Jul 07, 02:48
x4

Re: Why do AI-Controlled ship turn so very slowly?

Post by stooper88 »

I'll try my best to make it clearer but it's critical to understand that X4 isn't an RTS. X4 is a simulation. Each of the thousands of units in the game must be able to operate continuously and completely on their own, independently from any user input. As such, a model must be created which can handle all of the tasks and scenarios that the game can impose on any unit. Contrary to your belief otherwise, that model absolutely must be efficient to handle the scale of the game. Although it appears "inefficient" in the specific context that we're focused on, every compromise built into the engine is a deliberate tradeoff done in order to achieve efficiency, and in turn, playability.

To borrow from a cliche, we need to step back and see the forest from the trees. While directing one pilot to turn around seems trivial, directing thousands of other pilots to simultaneously carry about their own tasks is not so simple. Clicking and directing units in RTS games is not a fair comparison because the dynamics for such units are very limited and the complexity is very low. There's no need for collision detection and avoidance. You'll never task a unit in an RTS game to navigate through multiple sectors or carry out multiple compound tasks. Hence, RTS doesn't require any simulation framework and commands can be processed as directly and straightforwardly as you perceive they should be. This comparison is conflating simple pathfinding with full behavioral simulation, things which involve completely different magnitudes of complexity.

Returning to the example of crossing a street, a rudimentary process would impart no instructions other than to cross the street immediately upon receipt of the user command. This is what you're demanding. But a more sophisticated model takes multiple factors and actions into consideration, looking left, looking right, checking for ice or water, checking for traffic or crosswalk signals, etc. It allows for greater dynamics and immersion but at the cost of complexity. In order to offset the computational cost of that complexity, delay buffers are added to give operations more time to be carried out measuredly, again because thousands of other units are constantly and simultaneously undergoing their own determinations. These are all tradeoffs that don't exist in other games because the units in those games aren't embedded within a fully simulated environment.

But the AI doesn't need to check if it's safe to cross the street! We're telling them it's safe, so they should just do it instantly, right? No, because commands given to AI pilots must go through a sort of abstraction layer. You don't directly control the ship. You just give the AI pilots commands ("hints" if you prefer) at what their next objectives are. How to go about achieving those objectives is up to the AI pilots to figure out themselves. This allows you to direct a ship to a position anywhere, from less than 1km away, to as far as the opposite end of the galaxy, without having to hand hold each step of the way. It's what allows the AI to do the things they do for all the units in the game. There's no "safety off" mode or "simulation exemption" toggle that can be applied at the user's discretion. Every order carried out is done so through and within the confines of the simulation model.

But I want direct and immediate control! You can skip the abstraction layer any time, but you have to take the control away from the AI pilot. After all, they can only fly with the tools they're given, and that involves the simulation model. The only alternative is to pilot the ship yourself. Then you won't have to check left and right and can go full throttle at your will.
Last edited by stooper88 on Fri, 29. Nov 24, 23:14, edited 1 time in total.
Beware the pirate spacesuit patrols!
gorgofdoom
Posts: 227
Joined: Wed, 5. Dec 18, 18:48
x4

Re: Why do AI-Controlled ship turn so very slowly?

Post by gorgofdoom »

flywlyx wrote: Fri, 29. Nov 24, 22:41
In X4, weapons significantly outperform defensive equipment, especially since boosting is linked to shields. This makes it highly unlikely for the weaker side to escape if the stronger side knows how to chase effectively.
If this is truly their concern, they shouldn't consider the boost change, as it will significantly extend combat duration.
The tipping scales problem is solved by crew levels. Not sure a change to the boost mechanic would be a major concern; they're rebalancing all ships either way so if they need to adjust engagement time, they could more freely adjust hull / shield / DPS separately from mobility.

I think it would be a good thing to separate shield energy from boosting. IME the AI most reliably uses it to rush towards the enemy, which can be quite distressing concerning larger vessels that have huge shield pools. (gain basically nothing for burning 75% of their health)

It would disrupt the dynamic between shield choice and engine choice, however. I usually want the ship with the most boost-- how does one upgrade boosting if it's not tied to shields?
Raptor34
Posts: 2650
Joined: Sat, 12. Jun 10, 04:43
x4

Re: Why do AI-Controlled ship turn so very slowly?

Post by Raptor34 »

gorgofdoom wrote: Fri, 29. Nov 24, 23:11
flywlyx wrote: Fri, 29. Nov 24, 22:41
In X4, weapons significantly outperform defensive equipment, especially since boosting is linked to shields. This makes it highly unlikely for the weaker side to escape if the stronger side knows how to chase effectively.
If this is truly their concern, they shouldn't consider the boost change, as it will significantly extend combat duration.
The tipping scales problem is solved by crew levels. Not sure a change to the boost mechanic would be a major concern; they're rebalancing all ships either way so if they need to adjust engagement time, they could more freely adjust hull / shield / DPS separately from mobility.

I think it would be a good thing to separate shield energy from boosting. IME the AI most reliably uses it to rush towards the enemy, which can be quite distressing concerning larger vessels that have huge shield pools. (gain basically nothing for burning 75% of their health)

It would disrupt the dynamic between shield choice and engine choice, however. I usually want the ship with the most boost-- how does one upgrade boosting if it's not tied to shields?
My understanding is that the rebalancing is only in relation to the flight model, not other things. Or at least that's what the next couple sentences implied.
flywlyx
Posts: 1203
Joined: Sat, 15. May 21, 03:45
x4

Re: Why do AI-Controlled ship turn so very slowly?

Post by flywlyx »

stooper88 wrote: Fri, 29. Nov 24, 23:10 I'll try my best to make it clearer but it's critical to understand that X4 isn't an RTS. X4 is a simulation. Each of the thousands of units in the game must be able to operate continuously and completely on their own, independently from any user input. As such, a model must be created which can handle all of the tasks and scenarios that the game can impose on any unit. Contrary to your belief otherwise, that model absolutely must be efficient to handle the scale of the game. Although it appears "inefficient" in the specific context that we're focused on, every compromise built into the engine is a deliberate tradeoff done in order to achieve efficiency, and in turn, playability.
Just because Egosoft calls it a simulation doesn’t automatically make it more complex. All units in games—whether in an RTS or a sandbox like X4—are controlled by scripts. I’m not sure what specific model you’re referring to, but if you mean the scripting, I wouldn't call it particularly efficient.

Since you seem familiar with the X4's "model", maybe you can explain why Egosoft insists on using *get_safe_pos* in every situation. Why don't they implement the more widely used solutions others rely on?

I’m not looking for generic answers; let’s dive into the real issues.
gorgofdoom wrote: Fri, 29. Nov 24, 23:11 The tipping scales problem is solved by crew levels. Not sure a change to the boost mechanic would be a major concern; they're rebalancing all ships either way so if they need to adjust engagement time, they could more freely adjust hull / shield / DPS separately from mobility.

I think it would be a good thing to separate shield energy from boosting. IME the AI most reliably uses it to rush towards the enemy, which can be quite distressing concerning larger vessels that have huge shield pools. (gain basically nothing for burning 75% of their health)

It would disrupt the dynamic between shield choice and engine choice, however. I usually want the ship with the most boost-- how does one upgrade boosting if it's not tied to shields?
If you examine the script closely, you'll see that pilot level doesn't significantly impact combat performance. You can check the details here: https://steamcommunity.com/sharedfiles/ ... 3120616748
Having a separate gauge or shield for boosting doesn’t really bother me. My main concern is that they might pack too many changes into this modification and end up messing things up. However, maybe they’ll address all the issues effectively. I just hope they've carefully thought through what they're doing.
gorgofdoom
Posts: 227
Joined: Wed, 5. Dec 18, 18:48
x4

Re: Why do AI-Controlled ship turn so very slowly?

Post by gorgofdoom »

flywlyx wrote: Sat, 30. Nov 24, 05:53
If you examine the script closely, you'll see that pilot level doesn't significantly impact combat performance.
I disagree, for a long list of reasons. Lets start with rotation speed; which i'm admittedly assuming is an existing constraint based on a ships combined skill in the current version. (maybe it's gone? idk? doesn't feel that way while playing)

Any decrease in ability to rotate is a significant disadvantage in combat. If a ship can't rotate as fast as the other ship it will lose. Considering the AI in this game is never of perfect skill, a player without any skill based constraint to their rotation speed will always have some advantage in a fight against an 'equal' enemy. And that's not even considering our 'flight assist off' ability.

With the AI's current fight patterns the one that can rotate faster will find itself pointing toward the enemy first. That's a clear advantage. Did you never wonder how Amanzakrat (the pilot with the pegasus in the PAR plot) is basically invulnerable, but can still take damage?

Now, consider reaction times. A ship can be shot several times before it even starts the reaction timer-- reactions can be delayed several seconds after being hit the first couple times, in fact, or less depending on combined crew and pilot skill. That's an entire attack run completed by an enemy before the attacked ship will even try to move, at all, which can be minimized by skilled crew. I see this lack of reaction quite a lot, in recent videos, maybe it's not so obvious to others?

Now it's been a fair few years since i unpacked v4.2, but when i looked through those scripts... back then... i don't see anything that looks like what i remember in your link, and i've not seen up to date scripts, which may mean my opinion is out of date. I'll have to rut around in 7.1's guts sometime soon.
flywlyx
Posts: 1203
Joined: Sat, 15. May 21, 03:45
x4

Re: Why do AI-Controlled ship turn so very slowly?

Post by flywlyx »

gorgofdoom wrote: Sat, 30. Nov 24, 20:40 Now it's been a fair few years since i unpacked v4.2, but when i looked through those scripts... back then... i don't see anything that looks like what i remember in your link, and i've not seen up to date scripts, which may mean my opinion is out of date. I'll have to rut around in 7.1's guts sometime soon.
The author has update the guide based on 7.1 scripts so it should be up to date. But maybe it is not in the script, we would never know.
Post Reply

Return to “X4: Foundations”