Author Topic: Go to predicted UFO location  (Read 210 times)

Offline Sander Bouwhuis

  • Sergeant
  • **
  • Posts: 15
    • View Profile
Go to predicted UFO location
« on: August 11, 2019, 10:16:07 am »
When I turn on the 'Project predicted trajectory' setting, my interceptors go to the predicted UFO location, but then don't attack it. So, the UFO will just fly off and the interceptor just sits there idle.
Am I misunderstanding this feature? As it is now it is very annoying to constantly micromanage the interceptors (especially when you have 3 or so going to different UFOs at the same time).

Offline R1dO

  • Colonel
  • ****
  • Posts: 262
    • View Profile
Re: Go to predicted UFO location
« Reply #1 on: August 11, 2019, 04:05:51 pm »
You are not misunderstanding this feature. It is a bug that has been reported multiple times but turned out to be very hard to reproduce.

Most veteran players even advice against the feature (it has some other drawbacks as well according to them), even to the point that OXCE (a fork focused on more modding options and with Quality of life improvements) decided to remove that functionality.






Offline Sander Bouwhuis

  • Sergeant
  • **
  • Posts: 15
    • View Profile
Re: Go to predicted UFO location
« Reply #2 on: August 12, 2019, 07:15:41 pm »
Hard to reproduce?
Just send me a debug/logging build I can reproduce it 100% of the time. I have NEVER seen any time it actually worked.

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2121
    • View Profile
Re: Go to predicted UFO location
« Reply #3 on: August 12, 2019, 10:06:44 pm »
It's hard to reproduce and fix because the behavior changes very subtly between platforms, and even if we can reproduce it we can't exactly determine why it happens, nobody knows how to implement the feature 100% effectively. Perhaps I should add an (experimental) to the description.

Anyways let me know if the latest round of "fixes" helps. If not post your 100% reproducible save.

Online kevL

  • Colonel
  • ****
  • Posts: 226
    • View Profile
Re: Go to predicted UFO location
« Reply #4 on: August 12, 2019, 11:20:10 pm »
Sup,

i'm not sure but ...

Code: [Select]
/**
 * Gets the radian-angle to another Target on the Globe.
 * @param target - pointer to other target
 * @return, distance in radians
 */
double Target::getDistance(const Target* const target) const
{
    const double lonTarget (target->getLongitude());
    const double latTarget (target->getLatitude());

    if (AreSameTwo(
                _lon, lonTarget,
                _lat, latTarget))
    {
        return 0.;
    }
    // else the formula below returns NaN <-----

    return std::acos(
                std::cos(_lat)
                * std::cos(latTarget)
                * std::cos(lonTarget - _lon)
            + std::sin(_lat)
                * std::sin(latTarget));
}

might be worth a shot,



EDIT: I ended up writing this and sprinkling it around in various places (not necessarily the predict-destination routines exclusively)

Code: [Select]
/**
 * Checks if val1 or val2 (lon,lat) is NaN or Inf.
 * @note Checks validity of Globe coordinates.
 * @param val1 - x-coordinate
 * @param val2 - y-coordinate
 * @return, true if either val1 or val2 is NaN or Inf
 */
template<class _Tx>
inline bool isNaNorInf(
        const _Tx& val1,
        const _Tx& val2)
{
    if (   std::isnan(val1) || std::isnan(val2)
        || std::isinf(val1) || std::isinf(val2))
    {
        return true;
    }
    return false;
}
« Last Edit: August 12, 2019, 11:39:10 pm by kevL »

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2121
    • View Profile
Re: Go to predicted UFO location
« Reply #5 on: August 12, 2019, 11:44:48 pm »
Sup,

i'm not sure but ...

might be worth a shot,
Nice catch. I'm pretty sure we always use reachDestination first but can't hurt to add an extra check. I don't wanna add too much though because this is code that has to run repeatedly each tick.

In most cases a NaN will just return false anyways so it's mostly harmless.

Online kevL

  • Colonel
  • ****
  • Posts: 226
    • View Profile
Re: Go to predicted UFO location
« Reply #6 on: August 12, 2019, 11:48:23 pm »
ok, just something to keep a mind on i guess

Offline Sander Bouwhuis

  • Sergeant
  • **
  • Posts: 15
    • View Profile
Re: Go to predicted UFO location
« Reply #7 on: August 13, 2019, 11:24:12 pm »
Ok, I tested some versions (and attached a save game).

v2019-08-08 21:43
100% fails. The ufo coming from Antarctica overshoots the UFO and stays idling for a while until continuing pursuit.

v2019-08-12 03:30
Sort of works. I see the engagement window flashing but not actually opening. It then immediately pursues the UFO.

v2019-08-12 22:21
Sort of works. I see the engagement window flashing but not actually opening. It then immediately pursues the UFO.

v2019-08-13 12:58
Sort of works. I see the engagement window flashing but not actually opening. It then immediately pursues the UFO.


Is it because the UFOs are flying so fast that there will be a millisecond of engagement before the UFO outruns the Interceptor again?

Offline R1dO

  • Colonel
  • ****
  • Posts: 262
    • View Profile
Re: Go to predicted UFO location
« Reply #8 on: August 13, 2019, 11:49:51 pm »
You guessed correctly.

The crafts is able to intercept (because it is approaching from the front).
However the ufo speed is 2200, you interceptor can only do 2100, e.g. the ufo outruns your interceptor immediately.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 5062
  • Aaand we're back!
    • View Profile
    • My Wiki
Re: Go to predicted UFO location
« Reply #9 on: August 13, 2019, 11:58:44 pm »
But why does it happen only when Predict UFO Trajectory is turned on?
And not when it is turned off...

Offline R1dO

  • Colonel
  • ****
  • Posts: 262
    • View Profile
Re: Go to predicted UFO location
« Reply #10 on: August 14, 2019, 01:11:30 am »
Because the prediction is too good at it's job ;)

Joking aside, as far as i understand from the code (supsuper can probably explain it much better):

Predict Ufo Trajectory sets the destination of the craft to the exact point where they would meet, satisfying the condition for "interception" when both the craft and the ufo arrive there at the same moment.

Default behavior (option off) is for the craft to set it's destination to the last known position of the ufo.
For this collision course case it is highly likely for the craft destination to lie behind the actual meeting point. E.g. craft has to turn around and start chasing the ufo again. The condition for "interception" is not met, and since the ufo is faster we see the classic chase we all know too well.
« Last Edit: August 14, 2019, 01:17:09 am by R1dO »

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2121
    • View Profile
Re: Go to predicted UFO location
« Reply #11 on: August 14, 2019, 03:08:40 am »
New fix is up, let me know if it's more consistent between both modes. Mainly if there's still any cases where a craft gets "stuck" and stops chasing the UFO.

Online kevL

  • Colonel
  • ****
  • Posts: 226
    • View Profile
Re: Go to predicted UFO location
« Reply #12 on: August 14, 2019, 12:24:55 pm »
anyone?

Offline Sander Bouwhuis

  • Sergeant
  • **
  • Posts: 15
    • View Profile
Re: Go to predicted UFO location
« Reply #13 on: August 14, 2019, 10:15:27 pm »
Ok, I tested it with the new 2019-08-14 02:02 version.
It seems to work significantly better now. For me, it seems like this is fixed.
Maybe there are some edge cases, but now I can turn this option on again. Thanks for the swift fixes!