They should probably avoid live enemy turrets, even if there are no live stations near them, though.

johnbwatson 17 Nov 2015:

Noticed this issue a while ago, good to see it show up here.

If we're going to have ships path around turrets, it might also be good to have them path around hostile capital ships that aren't explicitly targeting them.

nms 18 Nov 2015:

Unfortunately, I think avoiding moving objects would require a significant change to the way nav paths currently work and would be harder and more computationally expensive.

johnbwatson 18 Nov 2015:

It strikes me as reasonably simple code.

<get array of threats to avoid, consisting of all hostile stations and turrets and all hostile capital ships not currently targeting me>

<Am I within 1.25x weapon/enemy avoidance range of one of these things?>

<If so, move perpendicular to the direction between me and closest of the things within avoidance radius>

<If not, or if destination is within avoidance radius, move toward destination>

nms 20 Nov 2015:

There are a few issues with that:
- If the threat is moving, it may not succeed at avoiding it. In fact, it may cause you to pass closer to the threat than you would have otherwise, unless you circle opposite to the direction it's moving.
- There may be other threats in the way. Always attempting to cirle around the nearest one should eventually cirle around all of them if they're stationary (or much slower than you) and you always circle in the same direction, but if they're moving it may not. And if you don't always cirle in the same direction, you may get stuck.
- It may result in very inefficient routes, compared with calculating a path ahead of time that avoids known hazards (stations and deadly stars). For instance, I encountered a system recently that was so congested, there was only one safe route in and out from the Korolov Shipping. The existing code handled this quite well, except for continuing to avoid abandoned stations.

To seem reasonably competent, the AI would have to plan a route that avoids known hazards, but have several possible behaviors when encountering an unexpected threat, such as:
- wait for it to get out of the way
- continue because it looks like it's going to get out of the way before you get too close
- plot a new route that avoids it (which may require backtracking and is complicated if it's moving)
- run directly away because it's too dangerous to risk getting any closer
- if there's no safe route to the destination, plot a route that passes near the least dangerous threat
- try to rush past it if you have escorts to distract it

johnbwatson 22 Nov 2015:

Of course we always circle in the same direction. Circling around is basically moving perpendicular to something in the direction that is closest to the overall trajectory. There's no situation in which the algorithm would result in circling around each individual object, at worst the ship would weave, which is reasonable given that it is passing between 2 hostiles that are shooting at it.

Turrets and capital ships would be avoided based on 1.25x the range of their gun turrets. There's not really a lot of room for error there, something that would have been avoided anyways will be avoided with a bit more space and travel time, and something that might have gotten quite a few bursts in would only get a few. It would probably have to circle in the opposite direction in the rare situation of encountering a capital ship that is faster than it heading towards it in a perpendicular direction, though.

The pre - generated routes with responses to unpredicted threats would probably be a lot better for processor speed, though. Probably would be hard to implement anything that complex, but simply following the current system for stations, adding turrets in with their own radii, removing both of those from the route planning system when destroyed, and circling around any capships as I described earlier would suffice.