Trying to understand "understand"

Can anyone tell me what’s wrong with my code here? I’ve put together a test game to try out an idea I had, but I can’t get part of it to work properly.

If I try “absorb chair”, the item is moved correctly to the Hidden room as it should be. But when I try “release chair”, I’m told “You can’t see any such thing.” I’ve looked through the Inform documentation but I can’t figure out what it is I’m doing wrong. Is it an issue with the ‘understand’ command?

Any ideas?

Hidden is not in scope. When you understand a thing as “release [something]”, that thing must be in scope. You want “release [any thing]”, and you’ll also need to override the rules blocking the action of reaching into Hidden.

[code]A thing can be free or absorbed. A thing is usually free.

Cell is a room. “An ugly cell.”

A chair is in cell. The description is “A chair.”

Hidden is a room. “Hidden away.”

Absorbing is an action applying to one thing. Understand “absorb [something]” as absorbing.
Releasing is an action applying to one thing. Understand “release [any thing]” as releasing.
Rule for reaching inside Hidden when the action name part of the current action is the releasing action: allow access. [This flourish ensures you won’t be able to, for instance, affect something that has been absorbed, other than by the releasing action.]

After absorbing chair when chair is in Cell:
move chair to Hidden;
now the chair is absorbed;
say “Done.”.

After releasing chair when chair is in Hidden:
move chair to Cell;
now the chair is free;
say “Done.”.[/code]

Thanks for that. I’d been beating my head against the wall trying to figure out what I was doing wrong but nothing was working.

You don’t need to mess with the rules for “reaching inside”. You only need to ensure that releasing applies to visible things (plus the change to the “understand” rule).

[code]A thing can be free or absorbed. A thing is usually free.

Cell is a room. “An ugly cell.”

A chair is in cell. The description is “A chair.”

Hidden is a room. “Hidden away.”

Absorbing is an action applying to one thing. Understand “absorb [something]” as absorbing.
Releasing is an action applying to one visible thing. Understand “release [any thing]” as releasing.

After absorbing chair when chair is in Cell:
move chair to Hidden;
now the chair is absorbed;
say “Done.”.

After releasing chair when chair is in Hidden:
move chair to Cell;
now the chair is free;
say “Done.”.
[/code]

Ah, right. Yeah, the significance of “visible” tends to trip me up.

That’s because ‘visible’ doesn’t mean ‘the player can see it’. Which has never made any sense.

‘In-scope’? ‘Scoped’? There is unfortunately no concise adjective I can think of that actually describes what ‘visible’ means in this context.

“Not necessarily touchable” is the precise denotation, as I understand the parser code.

“In the correct list to be considered when matching the names of objects in the player’s input”

No, that’s misleading. :slight_smile:

The “touchable” requirement (which is what “visible” annuls) is not applied when matching the player’s command! The parser does that matching by iterating through the current scope and checking objects.

Touchability is checked later, in the basic accessibility rule.

Who said anything about touchable? Visible does not mean touchable.

Visible means “not necessarily touchable”.

It means in-scope. Plenty of not necessarily touchable things are not ‘visible’.

[edit]I think we’re saying the same thing from different ends, but I have no idea how to explain it.[/edit]

Wait, I see the confusion. Inform uses the term “visible” in two ways, and we’re not talking about the same one.

“Visible”, as an adjective applied to things, means in-scope. This usage is defined in the Standard Rules:

The verb to be able to see (he is seen) implies the visibility relation.
Definition: Something is visible rather than invisible if the player can see it.

If you chew down through through the implementation of the visibility relation, you’ll find – first, a bad headache, and then a call to the I6 routine TestScope(), which does what you think.

However, the term “visible” in defining an action does not have this meaning. If you define three actions:

Foo1 is an action applying to one thing.
Foo2 is an action applying to one touchable thing.
Foo3 is an action applying to one visible thing.

…the third line does not mean “apply an extra visibility check”.

In fact you’ll find that Foo1 and Foo2 are treated exactly the same by the parser. (That is, the action requirement for new actions defaults to “touchable”) They have a flag which means that a touchability check occurs (in the basic accessibility rule).

And Foo3 is exactly the same, except that this flag is omitted! So that’s what I meant. The action does not necessarily apply to touchable things.

(It wouldn’t make sense to speak of a thing being not-necessarily-touchable – a thing either is touchable or it isn’t!)

No, no, that is exactly what I meant and we are talking about the same thing. ‘Visible’ in the context of defining an action means in-scope. It means the action can apply to anything that is already in scope. I’ve assumed they choose the word ‘visible’ because, unless you muck about with it, everything ‘in scope’ is also ‘visible’. That the items in scope are not necessarily touchable is rather secondary.

Besides, I’ve always felt that “Foo 1” should apply to any thing at all, in scope, or touchable, or not. And I guess I’m not alone. inform7.uservoice.com/forums/573 … e-in-appli

“Touchable” in that context means the action can apply to anything that is already in scope and also touchable. Every action applies to things that are in scope, with optional extra restrictions. In-scopeness isn’t a point of distinction between actions. (And if you want to change the scope of your action, you don’t do it when defining the action. You do it when definining the grammar.)

So it is clearest to not mention scopeness at all, when explaining action definitions. (Instead, discuss it with respect to grammar, which is where it applies.)

What about actions that apply to ‘any thing’? In-scope is the middle option, and includes all the things in the object graph starting from the location of the actor. Commands can apply to things that are not in scope.

When you define grammar to match ‘any thing’, the scope is the entire object tree.

The confusion seems to arise from the assumption that there’s “the scope” which you can either adhere to or ignore. That’s not true, actions always apply to a scope, defined by their grammar. So when you say “Understand “think about [any thing]” as thinking about”, you’re defining the scope of the noun token to be the entire object tree.

Not quite. You must define the action to apply to one visible thing otherwise it won’t work as expected.

So something like this won’t work.

Thinking about is an action applying to one thing. Understand "Think about [any thing]" as thinking about.

However, this will work.

Thinking about is an action applying to one visible thing. Understand "Think about [any thing]" as thinking about.

It would be much easier to understand if everyone uses this.

Thinking about is an action applying to one touchable thing.

Instead of this.

Thinking about is an action applying to one thing.

Especially as they mean exactly the same thing. It’s a bit counter-intuitive, but hey that’s Inform 7 for you! :wink:

Hope this helps.

Sure, but that’s beside the point. It won’t work as expected, but that doesn’t have anything to do with scope, which is determined entirely by the grammar line.

For example:

[code]Thinking about is an action applying to one thing. Understand “Think about [any thing]” as thinking about.

The cage is a room. Monkeys are in cage. The zoo is a room. The player is in zoo.[/code]

From this it should be clear that the parser recognized the noun which means the object was in scope regardless of what the action definition is.

Bumping this again as I’ve ran into another (slight!) snag.

When I try to absorb something I’ve written a response for, I get the correct result, but when I try something that doesn’t have a response I’d written, I get nothing aside from another line with the cursor on it.

Do I need to write a response for every single item or is there a way to cover them all with one simple command?