Possible change for npc Escorts:

An area for discussing new ideas and additions to Oolite.

Moderators: winston, another_commander

Post Reply
Switeck
---- E L I T E ----
---- E L I T E ----
Posts: 2411
Joined: Mon May 31, 2010 11:11 pm

Possible change for npc Escorts:

Post by Switeck »

In their "ENTER_WORMHOLE" section, they have:
"DESIRED_RANGE_ACHIEVED" = ("LOOK_FOR_BUSINESS");
Which means after reaching the wormhole (the desired range being in the wormhole), they immediately switch to looking for business/looking for a mothership to escort.

How about instead change that line to read:
"DESIRED_RANGE_ACHIEVED" = ("setStateTo: EXIT_WORMHOLE");
...so after entering a wormhole they aren't waiting on top of the exit point looking for a mothership that might run them over a couple seconds later.
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Re: Possible change for npc Escorts:

Post by Commander McLane »

Switeck wrote:
In their "ENTER_WORMHOLE" section, they have:
"DESIRED_RANGE_ACHIEVED" = ("LOOK_FOR_BUSINESS");
Which means after reaching the wormhole (the desired range being in the wormhole), they immediately switch to looking for business/looking for a mothership to escort.
No, they don't, because when entering their mother's wormhole they don't receive a DESIRED_RANGE_ACHIEVED message. The logical reason for this would be: wormholes tend to be quite a lot bigger than 1 meter, therefore a ship that collides with a wormhole and is removed will never achieve the desired range of 1 meter from its centre. Only if the wormhole has already collapsed will the escort get so close to its centre. Therefore I guess this line is in the AI for the purpose of an escort missing its mother's wormhole (being too late to enter). In that case it gets the DESIRED_RANGE_ACHIEVED message at some point, and will go looking for another mother, which is the sensible thing to do.

Here's some AI-log for the situation of an escort following its mother:

Code: Select all

15:06:38.018 [ai.takeAction]: Gemini Escort 478 to take action escortCheckMother
15:06:38.018 [ai.takeAction]: Gemini Escort 478 to take action pauseAI: 15
15:06:38.018 [ai.message.receive]: AI escortAI.plist for Gemini Escort 478 in state 'FLYING_ESCORT' receives message 'ESCORTING'. Context: handling deferred message, stack depth: 0
15:06:38.018 [ai.takeAction]: Gemini Escort 478 to take action setDesiredRangeTo: 0.0
15:06:38.018 [ai.takeAction]: Gemini Escort 478 to take action performEscort
15:06:46.627 [ai.message.receive]: AI escortAI.plist for Gemini Escort 478 in state 'FLYING_ESCORT' receives message 'ENTER WORMHOLE'. Context: <ShipEntity 0x1014cce00>{"Boa Class Cruiser"} wormholeEscorts, stack depth: 2
15:06:46.627 [ai.takeAction]: Gemini Escort 478 to take action setStateTo: ENTER_WORMHOLE
  15:06:46.627 [ai.message.receive]: AI escortAI.plist for Gemini Escort 478 in state 'FLYING_ESCORT' receives message 'EXIT'. Context: changing state, stack depth: 3
  15:06:46.627 [ai.message.receive]: AI escortAI.plist for Gemini Escort 478 in state 'ENTER_WORMHOLE' receives message 'ENTER'. Context: changing state, stack depth: 3
  15:06:46.627 [ai.takeAction]: Gemini Escort 478 to take action setDestinationToTarget
  15:06:46.627 [ai.takeAction]: Gemini Escort 478 to take action setDesiredRangeTo: 1.0
  15:06:46.627 [ai.takeAction]: Gemini Escort 478 to take action setSpeedFactorTo: 1.0
  15:06:46.627 [ai.takeAction]: Gemini Escort 478 to take action performFlyToRangeFromDestination
  15:06:46.627 [ai.takeAction]: Gemini Escort 478 to take action dropMessages: TARGET_LOST
15:06:51.728 [ai.message.receive]: AI escortAI.plist for Gemini Escort 478 in state 'ENTER_WORMHOLE' receives message 'WITCHSPACE OKAY'. Context: performHyperSpaceExit, stack depth: 0
15:07:17.478 [ai.message.receive]: AI escortAI.plist for Gemini Escort 547 in state 'ENTER_WORMHOLE' receives message 'EXIT'. Context: changing state, stack depth: 0
15:07:17.478 [ai.message.receive]: AI escortAI.plist for Gemini Escort 547 in state 'GLOBAL' receives message 'ENTER'. Context: changing state, stack depth: 0
15:07:17.479 [ai.takeAction]: Gemini Escort 547 to take action setStateTo: BEGIN_BUSINESS
  15:07:17.479 [ai.message.receive]: AI escortAI.plist for Gemini Escort 547 in state 'GLOBAL' receives message 'EXIT'. Context: changing state, stack depth: 1
  15:07:17.479 [ai.message.receive]: AI escortAI.plist for Gemini Escort 547 in state 'BEGIN_BUSINESS' receives message 'ENTER'. Context: changing state, stack depth: 1
15:07:17.479 [ai.message.receive]: AI escortAI.plist for Gemini Escort 547 in state 'BEGIN_BUSINESS' receives message 'EXITED WITCHSPACE'. Context: unspecified, stack depth: 0
15:07:17.479 [ai.takeAction]: Gemini Escort 547 to take action setStateTo: EXIT_WORMHOLE
  15:07:17.479 [ai.message.receive]: AI escortAI.plist for Gemini Escort 547 in state 'BEGIN_BUSINESS' receives message 'EXIT'. Context: changing state, stack depth: 1
  15:07:17.479 [ai.message.receive]: AI escortAI.plist for Gemini Escort 547 in state 'EXIT_WORMHOLE' receives message 'ENTER'. Context: changing state, stack depth: 1
  15:07:17.479 [ai.takeAction]: Gemini Escort 547 to take action setDestinationToCurrentLocation
  15:07:17.479 [ai.takeAction]: Gemini Escort 547 to take action setDesiredRangeTo: 7500.0
  15:07:17.479 [ai.takeAction]: Gemini Escort 547 to take action setSpeedTo: 50
  15:07:17.479 [ai.takeAction]: Gemini Escort 547 to take action performFlyToRangeFromDestination
15:07:17.508 [ai.takeAction]: Gemini Escort 547 to take action escortCheckMother
15:07:17.509 [ai.takeAction]: Gemini Escort 547 to take action pauseAI: 2.5
15:07:17.509 [ai.message.receive]: AI escortAI.plist for Gemini Escort 547 in state 'EXIT_WORMHOLE' receives message 'ENTERED_WITCHSPACE'. Context: handling deferred message, stack depth: 0
15:07:17.509 [ai.message.receive]: AI escortAI.plist for Gemini Escort 547 in state 'EXIT_WORMHOLE' receives message 'AWAY_FROM_PLANET'. Context: handling deferred message, stack depth: 0
15:07:17.509 [ai.message.receive]: AI escortAI.plist for Gemini Escort 547 in state 'EXIT_WORMHOLE' receives message 'ESCORTING'. Context: handling deferred message, stack depth: 0
15:07:17.509 [ai.takeAction]: Gemini Escort 547 to take action setDesiredRangeTo: 0.0
15:07:17.509 [ai.takeAction]: Gemini Escort 547 to take action setStateTo: NEXT_TARGET
  15:07:17.509 [ai.message.receive]: AI escortAI.plist for Gemini Escort 547 in state 'EXIT_WORMHOLE' receives message 'EXIT'. Context: changing state, stack depth: 1
  15:07:17.509 [ai.message.receive]: AI escortAI.plist for Gemini Escort 547 in state 'NEXT_TARGET' receives message 'ENTER'. Context: changing state, stack depth: 1
  15:07:17.509 [ai.takeAction]: Gemini Escort 547 to take action requestNewTarget
15:07:17.509 [ai.message.receive]: AI escortAI.plist for Gemini Escort 547 in state 'NEXT_TARGET' receives message 'TARGET_LOST'. Context: handling deferred message, stack depth: 0
15:07:17.509 [ai.message.receive]: AI escortAI.plist for Gemini Escort 547 in state 'NEXT_TARGET' receives message 'AEGIS_NONE'. Context: handling deferred message, stack depth: 0
15:07:17.509 [ai.message.receive]: AI escortAI.plist for Gemini Escort 547 in state 'NEXT_TARGET' receives message 'AEGIS_LEAVING_DOCKING_RANGE'. Context: handling deferred message, stack depth: 0
15:07:19.894 [Total_patrol]: Adding additional police.
15:07:20.008 [ai.message.receive]: AI escortAI.plist for Gemini Escort 547 in state 'NEXT_TARGET' receives message 'NOTHING_FOUND'. Context: handling deferred message, stack depth: 0
15:07:20.008 [ai.takeAction]: Gemini Escort 547 to take action switchLightsOff
15:07:20.009 [ai.takeAction]: Gemini Escort 547 to take action setStateTo: FLYING_ESCORT
  15:07:20.009 [ai.message.receive]: AI escortAI.plist for Gemini Escort 547 in state 'NEXT_TARGET' receives message 'EXIT'. Context: changing state, stack depth: 1
  15:07:20.009 [ai.message.receive]: AI escortAI.plist for Gemini Escort 547 in state 'FLYING_ESCORT' receives message 'ENTER'. Context: changing state, stack depth: 1
  15:07:20.009 [ai.takeAction]: Gemini Escort 547 to take action performEscort
15:07:20.009 [ai.message.receive]: AI escortAI.plist for Gemini Escort 547 in state 'FLYING_ESCORT' receives message 'DESIRED_RANGE_ACHIEVED'. Context: handling deferred message, stack depth: 0
15:07:20.138 [ai.takeAction]: Gemini Escort 547 to take action escortCheckMother
15:07:20.139 [ai.takeAction]: Gemini Escort 547 to take action pauseAI: 15
15:07:20.139 [ai.message.receive]: AI escortAI.plist for Gemini Escort 547 in state 'FLYING_ESCORT' receives message 'ESCORTING'. Context: handling deferred message, stack depth: 0
15:07:20.139 [ai.takeAction]: Gemini Escort 547 to take action setDesiredRangeTo: 0.0
15:07:20.139 [ai.takeAction]: Gemini Escort 547 to take action performEscort
You see that when entering the wormhole the only message received is WITCHSPACE OKAY. On the other side there's the EXIT message, and from there it goes via GLOBAL and BEGIN_BUSINESS to EXIT_WORMHOLE, where the ship receives a lot of irrelevant messages (irrelevant meaning that they're not acted upon in this situation). Finally it goes through state NEXT_TARGET and ends up in FLYING_ESCORT.

So the escort is doing exactly what it's supposed to do, and indeed escorts following their mother do not tend to collide with each other when exiting witchspace. (To be more precise: when you as player have followed and the new system is created, they are spawned in some distance to each other, not at the same coordinates.)
Switeck
---- E L I T E ----
---- E L I T E ----
Posts: 2411
Joined: Mon May 31, 2010 11:11 pm

Re: Possible change for npc Escorts:

Post by Switeck »

Seems like a kludge, even if it works.
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Re: Possible change for npc Escorts:

Post by Commander McLane »

Why? This is just how all AI works all the time. Receiving messages and reacting upon them is all an AI ever does. The art of AI writing is to choose which of the gazillion messages shall be acted upon in which way under which circumstances.
User avatar
DaddyHoggy
Intergalactic Spam Assassin
Intergalactic Spam Assassin
Posts: 8515
Joined: Tue Dec 05, 2006 9:43 pm
Location: Newbury, UK
Contact:

Re: Possible change for npc Escorts:

Post by DaddyHoggy »

Is that a US or an Imperial gazillion? :wink:
Selezen wrote:
Apparently I was having a DaddyHoggy moment.
Oolite Life is now revealed here
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Re: Possible change for npc Escorts:

Post by Commander McLane »

DaddyHoggy wrote:
Is that a US or an Imperial gazillion? :wink:
Imperial (Empire of Achenar) :wink:
Switeck
---- E L I T E ----
---- E L I T E ----
Posts: 2411
Joined: Mon May 31, 2010 11:11 pm

Re: Possible change for npc Escorts:

Post by Switeck »

In "ENTER_WORMHOLE" section, there is only sections for:
ENTER
"PLAYER WITCHSPACE" = (enterTargetWormhole);
"DESIRED_RANGE_ACHIEVED" = ("setStateTo: LOOK_FOR_BUSINESS");

...how the escorts return to other modes if they DON'T get "DESIRED_RANGE_ACHIEVED" is what seems a kludge.
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Re: Possible change for npc Escorts:

Post by Commander McLane »

Switeck wrote:
In "ENTER_WORMHOLE" section, there is only sections for:
ENTER
"PLAYER WITCHSPACE" = (enterTargetWormhole);
"DESIRED_RANGE_ACHIEVED" = ("setStateTo: LOOK_FOR_BUSINESS");

...how the escorts return to other modes if they DON'T get "DESIRED_RANGE_ACHIEVED" is what seems a kludge.
Yes, there don't need to be other sections, because there are no other messages which need to be reacted upon. Even the WITCHSPACE OKAY message, although received (see the log above), is irrelevant for the AI, because the ship doesn't need to react upon it. If it enters the wormhole, it is removed from the system, and thereby from existence. It dies. Only if the player happens to enter the system it was "jumping" to, the ship is recreated from scratch. Therefore it starts in GLOBAL state when recreated, and continues from there.

So the only relevant question is: what happens if the ship somehow fails to enter the wormhole? I answered that question above: the commands issued in the ENTER section cause the ship to head towards the location of the wormhole. So, if the wormhole does no longer exist, the ship will soon reach its former location, and DESIRED_RANGE_ACHIEVED is issued. This can only happen if the wormhole has disappeared, therefore there is nothing to follow anymore, therefore the ship is as of now an orphaned escort, therefore the logical way to go is to look for other business.

This is exactly what the ENTER_WORMHOLE state needs to do. What other sections need there to be?
Switeck
---- E L I T E ----
---- E L I T E ----
Posts: 2411
Joined: Mon May 31, 2010 11:11 pm

Re: Possible change for npc Escorts:

Post by Switeck »

Yep, definitely a kludge. Thanks for filling me in.
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Re: Possible change for npc Escorts:

Post by Commander McLane »

My Dictionary wrote:
kludge

an ill-assorted collection of parts assembled to fulfill a particular purpose.
• Computing: a machine, system, or program that has been badly put together
Perhaps I am being dense, but I don't understand how this definition fits to the ingenious (and rather well-thought-out) mechanism of a [wiki]state machine[/wiki].
User avatar
CommonSenseOTB
---- E L I T E ----
---- E L I T E ----
Posts: 1397
Joined: Wed May 04, 2011 10:42 am
Location: Saskatchewan, Canada

Re: Possible change for npc Escorts:

Post by CommonSenseOTB »

Commander McLane wrote:
My Dictionary wrote:
kludge

an ill-assorted collection of parts assembled to fulfill a particular purpose.
• Computing: a machine, system, or program that has been badly put together
Perhaps I am being dense, but I don't understand how this definition fits to the ingenious (and rather well-thought-out) mechanism of a [wiki]state machine[/wiki].
By this definition my numeric hud is definately a "kludge". :lol:

Vocabulary improvement +1. :) Learn something new everyday.
Take an idea from one person and twist or modify it in a different way as a return suggestion so another person can see a part of it that can apply to the oxp they are working on.


CommonSense 'Outside-the-Box' Design Studios Ltd.
WIKI+OXPs
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Re: Possible change for npc Escorts:

Post by Smivs »

Commander McLane wrote:
My Dictionary wrote:
kludge

an ill-assorted collection of parts assembled to fulfill a particular purpose.
I think that makes me a Kludge! :?
Commander Smivs, the friendliest Gourd this side of Riedquat.
Switeck
---- E L I T E ----
---- E L I T E ----
Posts: 2411
Joined: Mon May 31, 2010 11:11 pm

Re: Possible change for npc Escorts:

Post by Switeck »

Commander McLane wrote:
Perhaps I am being dense, but I don't understand how this definition fits to the ingenious (and rather well-thought-out) mechanism of a [wiki]state machine[/wiki].
I don't agree that it is ingenious. It works, but in a lackluster way...as I have seen escorts gets stuck doing nothing after their mother enters a wormhole.

"DESIRED_RANGE_ACHIEVED" = ("setStateTo: LOOK_FOR_BUSINESS"); ...for instance is to be used when it fails to reach its goal of actually entering the wormhole. I mistakenly thought that meant it reached its goal -- thus the whole point of me starting this message thread.

And if it manages to reach its goal, then it automagically gets reset to GLOBAL because it's actually been killed and replaced with the same shiptype in the new system. This means it regains lost/used missiles and is back to full energy (and NPC shields OXP).
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: Possible change for npc Escorts:

Post by Eric Walch »

The whole recent change to let escorts behave correct after jumping through a wormhole is a compromise.:

It must work when the escorts follow a mother through the wormhole (escorts arrive after the mother) AND it must work when escorts arrive before their mother jumps. (escorts arrive first)

The latter is for example the case when a ship with escorts follows the player. And because escorts fly in general faster than the mother, the escorts normally jump through the wormhole before heir mother does.

And AI is not so flexible to differentiate between every situation. It is often a challenge to write something that works in all cases.
Post Reply