figuring out what was included

I’m trying to set up a trick like this:

After telling something about:
   if the topic understood includes "[any visible thing]":
      say "Your utterance made inadvertent reference to [the thing that registered as being included just now]!"

So, if you’re in a room and there’s a fire hydrant visible, and you type TELL BOB ABOUT THE AWFUL FOREST FIRE, the game should respond with Your utterance made inadvertent reference to the fire hydrant!

The problem is, I can’t figure out how to identify the thing that caused the if statement to be true. I can use “[matched text]”, but that will just get me a snippet of text; I want to be able to capture the actual object.

Any ideas?

I think when you do a pattern matching test like that, a temporary variable gets set in the form of “the X understood”. So if you were testing for visible things, maybe “the thing understood” or “the [second] noun understood” would be set to the thing you want.

However, while this sounds reasonable, it doesn’t actually work (at least in 6G60). However, it’s not too hard to get it to work (again, at least in 6G60):

[code]The first noun understood is a thing that varies.

To decide which object is the noun understood:
(- noun -)

Instead of telling someone about something when the topic understood includes “[a visible thing]” (this is the verbal flailing rule):
say “You inadvertently referred to [the noun understood]!”[/code]

Playing around with the idea, however, it seems like there is an additional challenge if you only want it to work only when there is something non-present (X) that the player wants to talk about while something present with a similar name (Y) is there to interfere. As it stands, a command like >TELL BOB ABOUT ME responds a little nonsensically.

Here’s a complete scenario for your reference:

[code]“Topic Scan Test” by “Otis T. Dog”

Place is a room.

A fixed in place thing called a fire hydrant is in Place.

A man called Bob is in Place.

The first noun understood is a thing that varies.

To decide which object is the noun understood:
(- noun -)

Instead of telling someone about something when the topic understood includes “[a visible thing]” (this is the verbal flailing rule):
say “You inadvertently referred to [the noun understood]!”

Elsewhere is a room. It is east of Place.

An animal called a dog is in Elsewhere.

test me with “tell bob about dog / tell bob about what I had for breakfast / tell bob about forest fire / tell bob about me”[/code]

To decide which object is the noun understood:
	(- noun -)

This is simply the “noun” global variable in I7. You don’t have to go through that obfuscation.

So it is! I guess it gets reset even though for the purposes of the command “the noun” already means Bob at the start of action processing?

Yeah, unfortunately your example doesn’t quite work; no matter what object actually satisfies the includes condition, the game returns “You inadvertently referred to Bob!” (because Bob is always the noun).

This requires a bit of parser hacking, but it’s entirely possible. You can make a new Understand token which parses for an object without clobbering the noun or second noun variable, and instead just puts it into a variable you can use. (Code here based on the “third noun” example.)

The additional matched object is an object that varies. The additional matched object variable translates into I6 as "othernoun".

The understand token additional thing translates into I6 as "ADDITIONAL_THING_TOKEN".

Include (-
Global othernoun;
-) after "Definitions.i6t".

Include (-
[ ADDITIONAL_THING_TOKEN  x;
	x  =  ParseToken(ELEMENTARY_TT,  NOUN_TOKEN);
	if  (x  ==  GPR_FAIL  or  GPR_REPARSE)  return  x;
	othernoun  =  x;  return  GPR_PREPOSITION;
];
-).

After telling something about when the topic understood includes "[additional thing]":
	say "Your utterance made inadvertent reference to [the additional matched object]!".

The Library is a room. Alice is a woman in the Library. A paperback book is in the Library.

Test me with "tell alice about lamp / tell alice about book".

Result:

This looks promising. Which example is the “third noun” example? --I remember seeing that before, but I can’t find it in the I7 documentation.

EDIT: Oh, I remember now; it’s in the I6 documentation.

Hrm. And what if I wanted to match something using different scope rules? Like, say I define an attribute “referable,” so anything in the game can be a referable thing, and it will match against the topic understood no matter where it happens to be. Now the after rule would look like this:

After telling something about when the topic understood includes "[any referable thing]": say "Your utterance made inadvertent reference to [the additional matched object]!".

Thanks for your help. I6 inclusions are the one part of I7 that still makes my eyes cross.

In that case you’d need to adjust the I6 code underlying the [additional thing] token to make it look for all referable things. This is basically just adding a GPR to I7; the details have to be configured within the GPR.

Mike,

I know this topic is about a year old, but I came across something by happenstance that might be useful to you or anyone else revisiting this thread in the future.

It’s an extension by Mike Ciul called “Objects Matching Snippets” and seems to be intended to address the specific functionality you wanted. From the documentation:

[code]Objects Matching Snippets is a very simple extension that provides a convenient way to search for names of objects within a snippet such as the player’s command or the topic understood.

There are two relations that can be used for this: snippet-matching (“O is identified with S”) and snippet-inclusion (“O is named in S”). These correspond to the built-in phrases “S matches O” and “S includes O.”

Snippet-matching tests whether the name of object O matches the snippet S:

say "[The list of things identified with the topic understood] all match the phrase '[the topic understood]' in your command.";

Snippet-inclusion tests whether the name of object O appears in the snippet S:

say "The rooms [list of rooms named in the player's command] are all mentioned in your command."

Note that these are both object-to-snippet relations, so you can test them on rooms, directions, and regions as well as things.[/code]

The extension is here: raw.githubusercontent.com/i7/ex … ippets.i7x

I tried the example from the Documentation section, but I get multiple errors on Inform 6M62. It doesn’t like the phrase “Let item be a random exclamation identified with the topic understood;”?

[edit: FYI for anyone following this trail of breadcrumbs, see [url]https://intfiction.org/t/new-mini-extension-objects-matching-snippets/3278/1] for an earlier, working version of the “Objects Matching Snippets” extension. There may also be a newer version uploaded to the archives by the time you read this.]

Ah. I didn’t review it or test it myself, and upon closer inspection it looks like the extension is incomplete (which is probably why it’s not in the library or archive).

Oh, well.