Report an actor going -> Response (J)

This is the going rule from Graham Nelson’s Standard Rules:

Report an actor going (this is the describe room gone into rule): if the player is the actor: if the action is not silent: produce a room description with going spacing conventions; otherwise: if the noun is a direction: if the location is the room gone from or the player is within the vehicle gone by or the player is within the thing gone with: if the room gone from is the room gone to: continue the action; otherwise: if the noun is up: say "[The actor] [go] up" (A); otherwise if the noun is down: say "[The actor] [go] down" (B); otherwise: say "[The actor] [go] [noun]" (C); otherwise: let the back way be the opposite of the noun; if the location is the room gone to: let the room back the other way be the room back way from the location; let the room normally this way be the room noun from the room gone from; if the room back the other way is the room gone from or the room back the other way is the room normally this way: if the back way is up: say "[The actor] [arrive] from above" (D); otherwise if the back way is down: say "[The actor] [arrive] from below" (E); otherwise: say "[The actor] [arrive] from [the back way]" (F); otherwise: say "[The actor] [arrive]" (G); otherwise: if the back way is up: say "[The actor] [arrive] at [the room gone to] from above" (H); otherwise if the back way is down: say "[The actor] [arrive] at [the room gone to] from below" (I); otherwise: say "[The actor] [arrive] at [the room gone to] from [the back way]" (J); [*** *** ***] otherwise if the location is the room gone from: say "[The actor] [go] through [the noun]" (K); otherwise: say "[The actor] [arrive] from [the noun]" (L); if the vehicle gone by is not nothing: say " "; if the vehicle gone by is a supporter: say "on [the vehicle gone by]" (M); otherwise: say "in [the vehicle gone by]" (N); if the thing gone with is not nothing: if the player is within the thing gone with: say ", pushing [the thing gone with] in front, and [us] along too" (O); otherwise if the player is within the vehicle gone by: say ", pushing [the thing gone with] in front" (P); otherwise if the location is the room gone from: say ", pushing [the thing gone with] away" (Q); otherwise: say ", pushing [the thing gone with] in" (R); if the player is within the vehicle gone by and the player is not within the thing gone with: say ", taking [us] along" (S); say "."; try looking; continue the action; say ".";

I’m writing code that includes considerations for views of adjacent rooms, and response (J) is showing up all over the place when it’s not appropriate.
(It’s reporting people arriving in other rooms because the player saw them leave but is neither in the room they left nor the room they entered.)

(J) seems like a sort of catch-all, so I’m considering replacing it with “[The actor] moves out of view.”;

Does anyone know of any strange situations where the regular behavior of (J) is prefered (intended for)?

The place you usually see it is when using strange scope things, i.e. almost never. If “moves out of view” works better for your particular type of scope hacking it’ll probably work fine to change it. The thing to be cautious with is if the player can see both the source and the destination, so they aren’t actually out of view after moving, but you can deal with that if/when it comes up. (Also may want to use [move] rather than “moves” so it inflects properly based on the noun.)

Responses H, I, and J seem best understood in comparison to responses D, E, and F.

The first three explicitly mention the name of the room that the NPC enters (because the player isn’t there), while the latter three just say “arrives” (because the player is there and the room is implicit).

Responses H, I, and J kick in for any remote-from-the-player travel. Imagine a scenario where the player, in room A, is viewing room B via a crystal ball and an NPC arrives in room B from room C. An NPC entering room A (where the player actually is) will be described as arriving, while an NPC entering room B (that the player is viewing remotely) will be described as arriving at room B.

It’s true, though, that H, I, and J somewhat arbitrarily take the perspective of arrival instead of departure (like responses A, B, and C), leading to responses that suggest more knowledge than the player might have. If the player were using the crystal ball to spy on room C instead of room B, we might reasonably want a msg that says that the NPC departs room C to the , not arrives in room B from the , when the player might not even know the connection between B and C.

Edit: Didn’t see matt w’s post before writing this, but he seems to be making this point. I’d augment his “moves out of view” message to provide more detail, like this:

To move is a verb.
When play begins: now the describe room gone into rule response (J) is "[if the actor is visible][The actor] [arrive] at [the room gone to] from [the back way][otherwise][The actor] [go] [noun] from [the room gone from] and [move] out of view[end if]".

Also, what Draconis said.

Unfortunately, it seems as though Response (J) is appropriate half the time. Consider:

[code]Viewing room is a room. “You can see into the lab from here, but not the closet.”

lab is a room. closet is south of Lab.

After deciding the scope of the player when the location is Viewing room: Place Lab in scope.

Alex is a person in Closet.

Every turn:
if Alex is in Closet:
try Alex going north;
otherwise if Alex is in Lab:
try Alex going south.[/code]

Output:

The first message is good (except ungrammatical). The second message is less good.

But if we change response (J) to “[The actor] moves out of view” then we’ll get “Alex moves out of view” even when Alex is moving into view, which isn’t good.

What I think might be the best solution is to change the response message to check whether the actor is visible (at the end of the move) and otherwise print your new message. Like this:

When play begins: now the describe room gone into rule response (J) is "[if the actor is visible][The actor] [arrive] at [the room gone to] from [the back way][otherwise][The actor] [move] out of view[end if]".

and we get

as, it seems, we ought to. (Edited to accommodate Draconis’s point about making “move” adaptive.)

Thank you all for the responses so far. I’ve learned a lot from this.

What I’m currently trying to do is this:

[modify the standard rules to more robustly handle scope] When play begins: now the describe room gone into rule response (J) is "[report going response]". To say report going response: if the player can see the actor: let next room be the location of the actor; [find out the direction of the next room] let target direction be a direction; repeat with chosen direction running through directions: let test place be the room chosen direction from the location of the player; if the test place is the location of the actor: now the target direction is the chosen direction; say "[The actor] appears nearby to the [target direction]."; otherwise: say "[The actor] [move] out of view.";

This doesn’t work because “actor” isn’t recognized as a valid noun outside of the action itself. Maybe there is a way to pass a variable into a ‘to say’ block, or some other easier way to pass variables?

Basically, I’m trying to get the report to mention the direction they are visible in (when they suddenly pop into scope).

Does anyone know a better way to get this information, or some other hook I could use that preserves the parts of the current action?

When play begins:
	now the describe room gone into rule response (J) is "[report going response]".
	
The going actor is a person that varies.

Before an actor going:
	now the going actor is the actor.

To appear is a verb.
To move is a verb.

To say report going response:
	if the player can see the going actor:
		let target direction be the best route from the location to the location of the going actor;	
		say "[The going actor] [appear] nearby";
		if target direction is not nothing:
			say "[if target direction is down] below you[else if target direction is up] above you[else] to the [target direction][end if]";
	otherwise:
		say "[The going actor] [move] out of view".

Edited to handle up and down properly (avoid “to the up” and “to the down”).

Edit 2:

The “if target direction is not nothing” test above handles this situation and produces a vague “So-and-so appears nearby.” message.

You can also use “the person asked” wherever you have “the actor”–that’s a global variable that is set to the actor of the current action (I think). So:

[code]To move is a verb. [left this out earlier]

When play begins: now the describe room gone into rule response (J) is “[report going response]”.
To say report going response:
if the player can see the person asked:
let next room be the location of the person asked;
[find out the direction of the next room]
let target direction be a direction;
repeat with chosen direction running through directions:
let test place be the room chosen direction from the location of the player;
if the test place is the location of the person asked:
now the target direction is the chosen direction;
say “[The person asked] appears nearby to the [target direction]”;
otherwise:
say “[The person asked] [move] out of view”;[/code]

Note that, because of the way this rule is written, you should leave out the final period.

You can also get at the action variables for going if you keep everything strictly in the rule response text rather than invoking a say-phrase, because Inform knows that the rule response text will be invoked only from within the rule. But this leads to byzantine text substitutions like this:

[code]To move is a verb. To appear is a verb.

When play begins: now the describe room gone into rule response (J) is “[if the player can see the actor][The actor] [appear] nearby to the [best route from the location to the room gone to][otherwise][The actor] [move] out of view”.[/code]

Note also that this, and the other solutions involving direction-finding, will fail in cases (like my test case) where you can see into a room that you can’t move to from the location.

So if I wanted to add more code to the going behavior (such as in my example), should I consider just replacing the entire report rule?

I’d rather not add a global variable for something like this.

“The person asked” is built-in, for the purposes of persuasion rules and such - equivalent to the I6 “actor” global. Due to tradition the parser gives back its results in the form of a whole lot of global variables.

You could, but matt w’s suggestion to use the person asked works. So, matt’s example w/ my code minus the extra global (the person asked is gonna be there whether you use it or not):

Viewing room is a room. "You can see into the lab from here, but not the closet." 

The lab is a room.
[The lab is south of the viewing room.]
[The lab is up from the viewing room.]
[The lab is down from the viewing room.]
The closet is south of Lab.

After deciding the scope of the player when the location is Viewing room: Place Lab in scope.

Alex is a person in Closet.

Every turn:
	if location of Alex is Closet:
		try Alex going north;
	otherwise if location of Alex is Lab:
		try Alex going south.
		
When play begins:
	now the describe room gone into rule response (J) is "[report going response]".
	
To appear is a verb.
To move is a verb.

To say report going response:
	if the player can see the person asked:
		let target direction be the best route from the location to the location of the person asked;	
		say "[The person asked] [appear] nearby";
		if target direction is not nothing:
			say "[if target direction is down] below you[else if target direction is up] above you[else] to the [target direction][end if]";
	otherwise:
		say "[The person asked] [move] out of view".

Uncomment various definitions of the lab to check messages for different scenarios.

When is person asked set? That variable is used to track persuasion, and this function has nothing to do with persuasion.

Does person asked just arbitrarily become the player or actor of a given action? Do I have to say “now the person asked is the actor” ?

“Person asked” is something of a misnomer, and the documentation doesn’t explain it very clearly, but it always applies to the actor of the current action, even if it isn’t the result of persuasion. You don’t have to set it by hand.

Wow really?! That’s very useful. I wish I’d know that a long time ago.

In any case, I’d consider this problem solved. One other question though, can someone give me a brief primer on the application of verbs?

Such as [move]; moving? When should I be using them and how do I specify what they are?

The basic idea is that games can produce output in different tenses, person, and number, so any generalized code (like responses in the standard rules) ought to account for this. Even in a game without these kinds of changes, different actors can have different number (e.g., Alex vs. the wolves). So we hijack the verb definition and conjugation machinery that Inform uses to recognize assertions in the source code (e.g., verbs describing relations) and use it to get Inform to print out verbs in an adaptive way in responses. it’s usually enough to just give the infinitive in a verb definition (“To move is a verb.”) and Inform will work out the rest, but you can define the conjugation explicitly if necessary (“To move (he moves, they move, he moved, it is moved) is a verb.”).

There’s a good intro to this topic at the beginning of chapter 14 of the manual. §14.3 discusses defining new verbs like we did for “to move”.

I asked Emily about this, and she suggested that it be filed in Mantis under “doc issues”, if you’d be so kind. :slight_smile: We want clear documentation!

Well, if I can file it as a documentation bug that I didn’t understand that “filter” is a noun in the “map, filter, and reduce” section, I can certainly file this!