Horrible AI bug

For test results, bug reports, announcements of new builds etc.

Moderators: winston, another_commander, Getafix

Post Reply
Screet
---- E L I T E ----
---- E L I T E ----
Posts: 1883
Joined: Wed Dec 10, 2008 3:02 am
Location: Bremen, Germany

Horrible AI bug

Post by Screet »

Hi,

I bet you all know about the BEHAVIOUR_ATTACK_FLY_TO_TARGET_.... bug, but this time it was game-breaking.

Flying escort for the Cataclysm warship replica, I had to wait while it should shoot down three asteroids. The first run was OK, but I was later rammed by a kamikaze Terrorizer (which also went down) and had to redo the whole long mission...and then the warship replica was unable to shoot down the asteroids!

As it turns out, the BEHAVIOUR_ATTACK_FLY_TO_TARGET_x AI idea is completely broken. It's not possible to reach that position, as every target moves, thus the point can never be reached and the ship trying to do so can easily be shot down. In this case, the asteroid did not move, but rotate, thus making it impossible for the warship replica to reach that point. I did let the game run for roughly an hour - without any success or switch to another AI behaviour. Had to stop it and now I need to do the whole thing again. I report it here as it's not only a cataclysm thing, but can be experienced with anything.

Code: Select all

[dumpState]: State for <ShipEntity 0x29d770b8>{"Warship Replica" ID: 605 position: (-467451, 1.9965e+006, 375952) scanClass: CLASS_MILITARY status: STATUS_IN_FLIGHT}:
  [dumpState.entity]: Universal ID: 605
  [dumpState.entity]: Scan class: CLASS_MILITARY
  [dumpState.entity]: Status: STATUS_IN_FLIGHT
  [dumpState.entity]: Position: (-467451, 1.9965e+006, 375952)
  [dumpState.entity]: Orientation: (-0.618419 + 0.220496i + 0.720759j - 0.222366k)
  [dumpState.entity]: Distance travelled: 738540
  [dumpState.entity]: Energy: 1112 of 1112
  [dumpState.entity]: Mass: 899378
  [dumpState.entity]: Owner: <ShipEntity 0x29d770b8>{"Warship Replica" ID: 605 position: (-467451, 1.9965e+006, 375952) scanClass: CLASS_MILITARY status: STATUS_IN_FLIGHT}
  [dumpState.entity]: Flags: isShip, hasMoved, hasRotated, isSunlit, collisionTestFilter
  [dumpState.shipEntity]: Name: Warship Replica
  [dumpState.shipEntity]: Display Name: Warship Replica
  [dumpState.shipEntity]: Roles: <OORoleSet 0x28723f60>{cataclysm_warship_replica_1}
  [dumpState.shipEntity]: Primary role: cataclysm_warship_replica_1
  [dumpState.shipEntity]: Script: <OOJSScript 0x2871eec0>{"cataclysm-warship-replica-1" version 1.1}
  [dumpState.shipEntity]: Subentity count: 2
  [dumpState.shipEntity]: Behaviour: BEHAVIOUR_ATTACK_FLY_TO_TARGET_SIX
  [dumpState.shipEntity]: Target: <ShipEntity 0x12646780>{"Asteroid (Target 1)" ID: 615 position: (-467902, 1.99827e+006, 365325) scanClass: CLASS_ROCK status: STATUS_IN_FLIGHT}
  [dumpState.shipEntity]: Destination: (-458870, 1.99062e+006, 374540)
  [dumpState.shipEntity]: Other destination: (-475360, 2.01271e+006, 363887)
  [dumpState.shipEntity]: Waypoint count: 0
  [dumpState.shipEntity]: Desired speed: 200
  [dumpState.shipEntity]: Fuel: 0
  [dumpState.shipEntity]: Fuel accumulator: 0.00500017
  [dumpState.shipEntity]: Missile count: 8
  [dumpState.shipEntity.ai]: AI:
    [dumpState.ai]: State machine name: cataclysm_warshipReplica1AI.plist
    [dumpState.ai]: Current state: ATTACK_TARGET
    [dumpState.ai]: Next think time: 3522.45
    [dumpState.ai]: Next think interval: 0.125
  [dumpState.shipEntity]: Frustration: 0
  [dumpState.shipEntity]: Success factor: 565.949
  [dumpState.shipEntity]: Shots fired: 0
  [dumpState.shipEntity]: Time since shot: 103165
  [dumpState.shipEntity]: Spawn time: 351.462 (3170.91 seconds ago)
  [dumpState.shipEntity]: Hull temperature: 60
  [dumpState.shipEntity]: Heat insulation: 2
  [dumpState.shipEntity]: Flags: escortsAreSetUp, isFrangible, canFragment
I suggest to remove BEHAVIOUR_ATTACK_FLY_TO_TARGET_XYZ completely. It's no use at all, but disables the ship which goes into that state!

Screet
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Post by Eric Walch »

Yes, a very frustrating bug indeed. The bug can not be solved but with a small AI change you will not suffer from it. Open "warschipReplica1AI" and look for:

Code: Select all

    "ATTACK_TARGET" = {
        "DESTROYED_TARGET" = ("setStateTo: NEW_PHASE"); 
        ENTER = ("pauseAI: 2", "setSpeedFactorTo: 0.4", performAttack); 
        UPDATE = ("sendScriptMessage: checkForDestroyedTarget"); 
    };
Here change "performAttack" into "performMining". It should attack asteroids, but when mining asteroids they become also destroyed. I already mailed this solution to McLane. I even was in the impression this fix was already in his 1.1 update.
I redid this part of the mission quite often as it had some other problems. one was that on low FPS rates the gotoWaypointAI of the replica often did a quite long detour in his evasive actions.

But you are right that the performAttack has a big bug somewhere that it during his "attack" sometimes just flies in the wrong direction until it looses its target. And this particular part of the mission is relying on the ship killing the target.
I hope you are good in manual docking as you have to dock multiple times before you get a change to save the game. Mission of 1 hour? I Never timed it but after this time it is frustrating to redo it.
Screet
---- E L I T E ----
---- E L I T E ----
Posts: 1883
Joined: Wed Dec 10, 2008 3:02 am
Location: Bremen, Germany

Post by Screet »

Eric Walch wrote:
I hope you are good in manual docking as you have to dock multiple times before you get a change to save the game. Mission of 1 hour? I Never timed it but after this time it is frustrating to redo it.
Hehe...you should have seen some of my docking approaches in a Caduceus...I thought it would not be possible, but managed to dock without a scratch ;)

Yes, it was a bit frustrating. However, that can also be attributed to ATI drivers, as after that test run, every ship/asteroid/station went entirely black. I did manage to successfully do a workaround for the asteroids, but it was not possible to do the last fight with it:

If the player shoots down the asteroids for the warship replica, this counts as a success and the replica continues with the next part of the test!

The AI bug is however not McLanes, it's a general problem. I've seen many ships with the same trouble before...they fly on and on, but can never reach the desired point.

Screet
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

Any volunteers to write a complete new AI system that still takes the current plist state machines into account? ;-)

(Actually, Giles was working on this when he left, but I haven’t even looked at that code. I believe it was some way from working properly.)
User avatar
LittleBear
---- E L I T E ----
---- E L I T E ----
Posts: 2882
Joined: Tue Apr 04, 2006 7:02 pm
Location: On a survey mission for GalCop. Ship: Cobra Corvette: Hidden Dragon Rated: Deadly.

Post by LittleBear »

Would adding a :-

Code: Select all

"FRUSTRATED" = (performIdle, performAttack);
to ATTACK_SHIP states, work so that if it got stuck like this it chosen another attack tactic?
OXPS : The Assassins Guild, Asteroid Storm, The Bank of the Black Monks, Random Hits, The Galactic Almanac, Renegade Pirates can be downloaded from the Elite Wiki here.
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6683
Joined: Wed Feb 28, 2007 7:54 am

Post by another_commander »

What I don't understand is how the same attack code used to not have this problem in earlier Oolite versions. Ships have been trying to get to target's six or twleve since at least 1.65. It could be a change in a different part of the codebase that made this happen, but I also have to agree that it gets in the way of the game's fun. And it's a pain in the backside task trying to pinpoint it, too.

Off topic, the important thing in the warship test mission is to get the asteroids destroyed. It does not matter who destroys them, as long as they are blown up. There is no need to restart the mission if the warship gets stuck trying to shoot them. Just give him a hand and the mission proceeds.
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Post by Eric Walch »

another_commander wrote:
What I don't understand is how the same attack code used to not have this problem in earlier Oolite versions. Ships have been trying to get to target's six or twelve since at least 1.65. It could be a change in a different part of the codebase that made this happen, but I also have to agree that it gets in the way of the game's fun. And it's a pain in the backside task trying to pinpoint it, too.
An other possibility is that it always behaved bad, but we now just notice it because of the better debugging tools.

What could help is adding a FRUSTRATED message during attack. e.g. when flying for over 30 second off target. Same with performFaceDestination. That also does not generate FRUSTRATED messages. By itself a FRUSTRATED should never occur but it gives a script an escape possibility.
e.g. performCollect send such a message that was very useful during the unscoopable cargo bug. With a FRUSTRATED message you can decide to change tactics. e.g. when performFaceDestination does not work within a reasonable time, doing a performTumble in between. Or when an attack fails break of the attack.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

FYI, ships don’t rack up frustration points while in BEHAVIOUR_FLY_TO_TARGET_SIX/TWELVE mode. They probably should, and there should probably even be a default behaviour change if the AI doesn’t do anything in response to FRUSTRATED in those cases.
Post Reply