Page 1 of 1
Possible change for npc Escorts:
Posted: Sat Jun 18, 2011 10:51 pm
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.
Re: Possible change for npc Escorts:
Posted: Tue Jun 21, 2011 1:15 pm
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.)
Re: Possible change for npc Escorts:
Posted: Tue Jun 21, 2011 3:53 pm
by Switeck
Seems like a kludge, even if it works.
Re: Possible change for npc Escorts:
Posted: Tue Jun 21, 2011 9:30 pm
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.
Re: Possible change for npc Escorts:
Posted: Tue Jun 21, 2011 9:31 pm
by DaddyHoggy
Is that a US or an Imperial gazillion?
Re: Possible change for npc Escorts:
Posted: Tue Jun 21, 2011 9:40 pm
by Commander McLane
DaddyHoggy wrote:Is that a US or an Imperial gazillion?
Imperial (Empire of Achenar)
Re: Possible change for npc Escorts:
Posted: Wed Jun 22, 2011 3:08 am
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.
Re: Possible change for npc Escorts:
Posted: Wed Jun 22, 2011 4:33 pm
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?
Re: Possible change for npc Escorts:
Posted: Wed Jun 22, 2011 6:45 pm
by Switeck
Yep, definitely a kludge. Thanks for filling me in.
Re: Possible change for npc Escorts:
Posted: Wed Jun 22, 2011 7:05 pm
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].
Re: Possible change for npc Escorts:
Posted: Wed Jun 22, 2011 9:36 pm
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".
Vocabulary improvement +1.
Learn something new everyday.
Re: Possible change for npc Escorts:
Posted: Wed Jun 22, 2011 9:51 pm
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!
Re: Possible change for npc Escorts:
Posted: Thu Jun 23, 2011 11:03 am
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).
Re: Possible change for npc Escorts:
Posted: Thu Jun 23, 2011 9:08 pm
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.