intfiction.org

The Interactive Fiction Community Forum
It is currently Sat Feb 23, 2019 4:57 am

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: Wed Feb 06, 2019 4:54 am 
Offline
User avatar

Joined: Fri Aug 14, 2009 10:01 pm
Posts: 22
I really want to allow the player to abbreviate the consulting command (among other related commands) to eg "look up pavlova" but I'm struggling to apply the examples for supplying missing nouns to this case. When I try the following minimal code:

Code:
The Library is a room. A book is in the Library.

Understand "look up [text]" as consulting it about.

Rule for supplying a missing noun while consulting:
   now the noun is the book.
   
Instead of consulting the book about "pavlova":
   say "It claims pavlovas were invented in Australia: clearly this book cannot be trusted!"


it fails to compile with the error:
Quote:
Problem. The grammar you give in 'Understand "look up [text]" as consulting it about' is not compatible with the Consulting it about action (defined as 'applying to one thing and one topic') - the thing you suggest this action should act on is not an object at all.


If I remove the "understand" rule it compiles and "consult book about pavlova" works fine, but "look up pavlova" predictably throws an error.

(I'm also fuzzy about "consulting" vs "consulting it about", but the compiler throws a different error if I have "while consulting it about", or if I have "understand ... as consulting", so I assume that this way around is correct in that respect at least. For whatever reason.)

Am I missing something; or is there, shall we say, a gap in Inform's functionality here?


Top
 Profile Send private message  
Reply with quote  
PostPosted: Wed Feb 06, 2019 9:11 am 
Offline

Joined: Tue Mar 09, 2010 2:34 pm
Posts: 5568
Location: Burlington, VT
I think you can only supply a missing noun with one-noun-only activities. Inform doesn't know that, in the incomplete grammar line, it's the first noun that's supposed to be missing. You can see why this would be a problem with actions applying to two things; with actions applying to a thing and a topic it would in theory be unambiguous, but it doesn't work.

The thing is that it's almost never worth fiddling with supplying a missing noun/second noun to get it to work right--these can be convenient but if they're not convenient you can basically always work around it with a new action. So you could do this:

Code:
Consulting vaguely is an action applying to one topic. Understand "look up [text]" as consulting vaguely.

Check consulting vaguely when the player cannot touch the book: say "You can't find the book." instead.

Carry out consulting vaguely: try consulting the book about the topic understood.


Top
 Profile Send private message  
Reply with quote  
PostPosted: Wed Feb 06, 2019 2:16 pm 
Offline
User avatar

Joined: Fri Aug 14, 2009 10:01 pm
Posts: 22
Curiously I can get a missing noun to work when the action takes two things, though it requires a bit of finessing as when there's one noun Inform naturally assumes that it's the second noun missing. eg adding the following code:

Code:
Definition: a person is other if it is not the player.
The librarian is a woman in the Library.

Understand "ask [someone] about [something]" as interrogating it about. Interrogating it about is an action applying to two visible things.

Rule for supplying a missing second noun while interrogating:
   if the number of other people in the location is 1:
      now second noun is noun;
      now noun is a random other person in the location.
      
Understand "ask about [something]" as interrogating it about.

Instead of interrogating the librarian about the book:
   say "'I've been meaning to weed that, actually,' she says."


So it seems to be just an issue when one of the "nouns"/parameters/arguments is a topic instead of a thing. (Oh: I'm reminded of something else I struggled with, that when you're working with stored actions, you can refer to eg the second noun of the action, but if it's a topic it returns "nothing" instead, and there's no documented way to refer to the topic parameter.)

A shame, but creating a new "consulting vaguely" action sounds like the perfect way around this, thank you!


Top
 Profile Send private message  
Reply with quote  
PostPosted: Wed Feb 06, 2019 10:46 pm 
Offline

Joined: Tue Mar 09, 2010 2:34 pm
Posts: 5568
Location: Burlington, VT
Oh, that's a clever way of using the supplying a missing second noun activity to effectively supply a missing noun for two-thing activities! What I meant was that there's no way to get the supplying a missing noun activity to run here, but you can use that to put the noun the player entered into the second-noun spot.

As for accessing the topic parameter in a stored action, I poked around in the Inform 6 templates a bit, and I found this:

Quote:
An action which involves a topic – such as the one produced by the command LOOK UP JIM MCDIVITTIN ENCYCLOPAEDIA – cannot be tried without the text of that topic (JIM MCDIVITT) being available.That’s no problem if the action is tried in the same turn in which it is generated, because the text will stillbe in the command buffer. But once we store actions up for future use it becomes an issue. So when westore an action involving a topic, we record the actual text typed at the time when it is stored, and thisgoes into array entry 5 of the block. Because that in turn is indexed text, and therefore a block value on theheap in its own right, we have to be a little more careful about destroying and copying stored actions thanwe otherwise would be.


This makes it sound like it wouldn't be straightforward to access the topic as a snippet (which is what "the topic understood" really is--there's some more discussion of that here, with more discussion about what topics are farther down if you're a glutton for punishment). Snippets are always treated as excerpts of the current command--they're just stored as a number that tells you which word the snippet starts on and how many words it goes. It seems from the I6 templates that when a stored action involves a topic, Inform stores the whole command (or maybe just the words from the relevant snippet) as text as part of the stored action. Then if it ever needs to refer back to that, it copies the current command into a buffer, loads the old stuff into the current command, does whatever it needs to do in order to retrieve the old topic understood as a snippet, and reloads the current command from the buffer.

It seems very complicated!


Top
 Profile Send private message  
Reply with quote  
PostPosted: Thu Feb 07, 2019 12:37 pm 
Offline

Joined: Sat Jan 23, 2010 4:56 pm
Posts: 5921
The flip side of this is that the snippet (topic understood) is a subset of the player's command. The only useful thing you can with it is match it against topics (usually expressed in a table). So it's often possible to do the matching right away, and then store a table line or associated game object rather than trying to store the snippet.


Top
 Profile Send private message  
Reply with quote  
PostPosted: Thu Feb 07, 2019 1:33 pm 
Offline

Joined: Sat Feb 13, 2016 6:26 pm
Posts: 168
If I may jump in with my own relevant (?) story. I am in the middle of getting a tv set to work and the player being able to change the channels.

I start with a "changing it channel to" to get player commands like "change/switch/turn [something] to channel/-- [number]".

Then, I want to also get the cases where the player omits either or both parts, as in:

* change channel to 3 (noun missing)
* change television channel (number missing)
* change channel (both number and noun missing)

I am up for making separate actions for each case. For example, if the number is missing, the relevant action can increment the channel number; if the noun is missing, the "check rule" checks whether the television is in the location.

I have never successfully used the "supplying a missing noun" solution, so I am not aware of the drawbacks. Nevertheless, I must admit that the multiple action solution can get a little tedious in such a case.

The other thing is that I don't know how to get the game to prompt for missing snippets, as the default actions do, for example:

Quote:
>ask about vinegar
Whom do you want to ask?

>centurion
The centurion says "Yeah, vinegar rocks!"


I have no idea how to achieve this. Moreover, if I catch missing snippets with actions that don't regard them as missing, I probably cannot get my game to make such interactions, where the player can complete her sentence with multiple prompts.

(If this is irrelevant, I apologise; feel free to make it into a separate post.)


Top
 Profile Send private message  
Reply with quote  
PostPosted: Fri Feb 08, 2019 12:32 am 
Offline
User avatar

Joined: Fri Aug 14, 2009 10:01 pm
Posts: 22
@zarf - My problem is that I've got more columns than the basic topic/reply table so that I can track whether it's something someone might only confide in you once they trust you, and whether or not they've already said it so they can chide you, and such like. Which makes the corresponding rule more complex, which means I don't want to have to repeat it elsewhere and risk the two locations getting out of sync if I tweak things.

<thinks> I could possibly do something fancy with shifting that complexity into an activity which writes at least the textual output into a global variable which the report rule prints immediately, while the "3 turns from now" rule prints only later. It feels like a kludge, and I don't like global variable for kludgy purposes because I suspect them of breeding while my back is turned, but otoh if it works...

I've also toyed with the idea of adding a "unique key" column to the table so I could store that, but that seems overkills and a maintenance nightmare.

My solution for now is to sit down and take a hard look at my story and tell myself very sternly that I don't actually *need* this function, I just *want* it, and I can deal with this particular scene a different way. :-)


Top
 Profile Send private message  
Reply with quote  
PostPosted: Fri Feb 08, 2019 1:24 am 
Offline
User avatar

Joined: Fri Aug 14, 2009 10:01 pm
Posts: 22
@GiannisG - For the first one, I'd first consider whether you really need a noun other than the number. If the only thing in your story world whose channel can be changed is the television, then just a changing to [number] rule should do the job and let the rule (rather than the player) specify the TV - then the "supply a missing noun" rule becomes a lot simpler.

But if you also have radios, and elevators going to different floors, and ovens at different temperatures, then you might want a generic rule that can cover all these cases, and then you do need a changing [something] to [number] rule -- and, playing around with it somewhat, I think trying to write a missing noun rule is going to run into the same problem with numbers than I have with topics.

What I'd do would be pick the command I want the player to use (probably the shortest version I can think of as no-one wants to be typing extra words) and then use the item's description to encourage them to use it, eg

> x tv
The television is an old black-and-white box complete with bunny-ear antennae. It has four buttons to let you switch the channel. It is currently switched to 4.

Then you don't have to worry about "change/turn/set/select" because you can rely on the player echoing your own words by using "switch". They might try "switch tv/television/channel/it to 3", or possibly even "switch to channel 3", but those seem less likely and are few enough to be dealt with by, oh...

Code:
Understand "switch to [number]" as switching to.
Understand "switch tv to [number]" as switching to.
Understand "switch television to [number]" as switching to.
Understand "switch it to [number]" as switching to.
After reading a command:
   if the player's command includes "channel", delete the matched text.


Or if you do want/need to include the tv as a noun then:

Code:
Understand "switch [something] to [number]" as switching it to.
After reading a command:
   if the player's command includes "channel", delete the matched text.
Understand "switch to [number]" as a mistake ("You need to say what you're switching.").
Understand "switch [something]" as a mistake ("You need to say what number you're switching it to.").
Understand "switch" as a mistake ("You need to say what number you're switching it to.").


I'm not clear on how to get the computer to prompt for missing nouns either. Running a "rules all" command before a "take" I see it does consult the "does the player mean" rules first. Emily Short's "Overview of rules consulted in play" mentions the "asking which do you mean activity" - this is in the documentation at 18.31 but I can't see how to intentionally invoke it.

Code:
Understand "switch to [number]" as switching to.
Switching to is an action applying to one number.
Understand "switch" as switching to.

Report switching to:
   say "Now the television is switched to the channel [number understood]."


gives me the curious response "You may not name an object - since the same code happily tells me "You must name a noun" when I change all the 'numbers' to 'things' I suspect Inform may not deal well with non-things here either, and using the "understand" rules may be your best bet.


Top
 Profile Send private message  
Reply with quote  
PostPosted: Fri Feb 08, 2019 11:47 am 
Offline

Joined: Tue Mar 09, 2010 2:34 pm
Posts: 5568
Location: Burlington, VT
Zeborah wrote:
Then you don't have to worry about "change/turn/set/select" because you can rely on the player echoing your own words by using "switch".


Well, as a matter of design, you can't rely on this! Players will use whatever word is stuck in their heads and it's best to catch as many synonyms as possible.

As for prompting for missing nouns, you're entirely right--Inform doesn't deal with non-things well here. For my sins I have spent a little time poking around the disambiguation code, and it's in the parser internals under "NounDomain" if I remember correctly, which is the part of the parser that tries to resolve snippets into nouns--it finds things that match, runs Does The Player Mean rules and those obscure rules that default to things you're holding, and if there's still a tie it runs the disambiguation activities. So those just don't work for non-nouns.

I looked in the I6 templates to see where the curious response you got came from and encountered this annotation:

Quote:
(i) For an out of world action, we set the |meta| flag. Otherwise:
(ii) If either the noun or second noun is a topic, then this is an action
arising from parsing (such actions do not arise through the "try" phrase,
unless by stored actions in which case this has all happened before and
doesn't need to be done again) -- the parser places details of which words
make up the topic in the I6 global variables |consult_words| and |consult_from|.
We convert them to a valid I7 snippet value.
(iii) If either the first or second noun is supposed to be an object but
seems here to be a value, or vice versa, we stop with a parser error. (This
should be fairly difficult to provoke: NI's type-checking will make it
difficult to arrange without I6 subterfuges.)
(iv) If either the first or second noun is supposed to be an object and
required to exist, yet is missing, we use the "supplying a missing noun"
or "supplying a missing second noun" activities to fill the void.


The thing you did falls under (iii), so it looks like you accomplished something that's supposed to be fairly difficult! But yeah, it looks like this won't work for these purposes.

...as for supplying a missing noun in commands like "ask about vinegar," I hacked this up that's meant to simulate that:

Code:
Lab is a room. Debbie Downer and Pollyanna are women in Lab.

Instead of asking Debbie Downer about something, say "Debbie says, 'Oh, [the topic understood] won't turn out well.'"

Instead of asking Pollyanna about something, say "Pollyanna says, 'Yay, [the topic understood]!'"

Vaguely asked is a truth state that varies. The stored topic is a text that varies.

Vague asking is an action applying to one topic. Understand "ask about [text]" as vague asking.

Carry out vague asking:
   say "Who do you want to ask that?";
   now the stored topic is the substituted form of "[the topic understood]";
   now vaguely asked is true.

Supplying a missing person is an action applying to one thing. Understand "[person]" as supplying a missing person when vaguely asked is true.

Carry out supplying a missing person:
   now vaguely asked is false;
   try asking the noun about "[the stored topic]".


I was kind of surprised that the last line worked, directly trying asking about with a text substitution, but it does, so yay! (I wouldn't count on this not to break though.)


Top
 Profile Send private message  
Reply with quote  
PostPosted: Fri Feb 08, 2019 12:07 pm 
Offline

Joined: Sat Jan 23, 2010 4:56 pm
Posts: 5921
Quote:
Or if you do want/need to include the tv as a noun


You do, said the narrator.


Top
 Profile Send private message  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: Bing [Bot] and 13 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group