Parser doc bug with lists?

Daniel,
I took your suggestion about plurals and singulars, and I was able to remove the parser override. It almost worked.

The plural of pelt is asdfasdf.
The plural-pelts are in the pelt rack.
The printed name is "pelts".
Understand "pelts" as  pelt rack.

However, when ‘x pelts’ is entered, I get
In the pelt rack are a wolf pelt, a beaver pelt, weasel pelt, mink pelt, coyote pelt, raccoon pelt, an unknown pelt, and a pelts
I don’t understand this enough to remove that last noun “pelts”.

1 Like

If you’ve already made the “pelt rack” as an object, you don’t also need the “plural-pelts”.

The plural of pelt is asdfasdf.
Understand "pelts" as the pelt rack.

I think I finally have it.

A pelt is a kind of thing.
A peltz rack is a container in cottage interior. "Many pelts hang from the wall."
The beaver pelt, weasel pelt, mink pelt, coyote pelt, raccoon pelt, wolf pelt, and an unknown pelt are pelts in the peltz rack. 
	
The plural of pelt is asdfasada. 	[Remove the plural name of pelts.]
The printed name of peltz rack is "pelts rack".
Understand "pelts" as the peltz rack.

Thanks everyone for your patience and suggestions. This was quite a learning experience.

p.s. Why is the parser override so bad? The docs even show how to do it:
Section 18.33 Changing a player’s command.

When you’re trying to intercept a specific action in an “after reading a command” rule, you need to write out every possible phrasing the parser would accept. And inevitably people will forget some.

How many synonyms for “examine” can you think of off the top of your head? There are seven in the Standard Rules: “examine”, “x”, “watch”, “check”, “describe”, “look at”, and “look”. Some extensions add more, such as “ex”. Did you remember to include all seven of these?

On the other hand, how many ways of referring to the pelts can you think of? You’ve handled “pelts”; how about “the pelts” or “some pelts” or “those pelts”? Do you know which of those the parser can handle by default?

Are you trying to match the entire command? If so, “LOOK THEN X PELTS” or “X PELTS THEN LOOK” won’t work. If not, how certain are you that no other verb ends in X?

Is examining the only action the player will ever try to do to the pelts? How certain are you of that? What if they try to SEARCH PELTS or TOUCH PELTS? How many synonyms does each of those verbs have?

It’s an old adage in programming that you should avoid duplicating code when possible, because the two versions will inevitably get out of sync. The parser is a monstrously complex bit of code, and it’s extremely hard to write your own version for this one specific action that is guaranteed to work in the same way.

“After reading a command” rules are, of course, part of the language. But if you look at the examples of these rules in the documentation, you’ll notice that none of them specifically cares about what action is happening. Replacing all instances of one word with another, like “North by Northwest”, is fine. It’s when you’re trying to replicate the parsing machinery (i.e. determining what action the player is trying to take) that problems arise.

1 Like

Daniel is right- doing battle with the parser is almost always a bad idea, usually ( as he outlines) leading to having to deal with a mounting cascade of ‘yes, but what if the player types …’ scenarios you hadn’t first thought of. When I said it was an inelegant solution I should perhaps have been stronger and called it ‘crude and ill-advised’.

Even Daniel’s suggested solution of hacking the meaning of ‘pelts’ (which opens a smaller skirmish against the parser) leads to unwanted side-effects when the player asks to do things with ‘pelts’ other than examine them- ‘take pelts’ for example- which the player will expect, according to usual parser behaviour, to lead to an attempt to take each individual pelt object in turn leading to an inventory full of pelts- now leads to an unexpected attempt to take (i) in your original scenario the pelts scenery-object (which fails with the jarring response ‘That’s hardly portable.’) or (ii) in your latest scenario, the following:

Cottage interior
Many pelts hang from the wall.

>take pelts
Taken.

>i
You are carrying:
  a pelts rack
    a beaver pelt
    weasel pelt
    mink pelt
    coyote pelt
    raccoon pelt
    wolf pelt
    an unknown pelt

When you find yourself tempted to open battle with the parser, it is almost always worthwhile reanalysing the issue and looking for a different approach.

The fundamental problem you’re battling with here is that you’re trying to give two things the same name and then to make assumptions as to which of the two the player means when she refers to that name. The complicating factor is that the clash is in the plural of one object clashing with the singular name of the other, which prevents the parser’s usual disambiguation mechanism (‘Which do you mean, …’) from kicking in.

A simple tweak to the name of the rack and a nudge to the parser to discourage it from jumping to conclusions (that ‘pelt’ refers to the pelt rack rather than some individual pelt) probably solves most of your problems:

Cottage interior is a room.

A pelt is a kind of thing.
A pelt rack is a container in cottage interior. "Many pelts hang from a rack on the wall."
The beaver pelt, the weasel pelt, the mink pelt, the coyote pelt, the raccoon pelt, the wolf pelt, and an unknown pelt are pelts in the pelt rack. 
Does the player mean doing something with the pelt rack: it is unlikely.
Cottage interior
Many pelts hang from a rack on the wall.

> x pelts
You can't use multiple objects with that verb.

>x rack
In the pelt rack are a beaver pelt, a weasel pelt, a mink pelt, a coyote pelt, a raccoon pelt, a wolf pelt and an unknown pelt.

>x pelt
Which do you mean, the pelt rack, the beaver pelt, the weasel pelt, the mink pelt, the coyote pelt, the raccoon pelt, the wolf pelt or the unknown pelt?

>take pelt
Which do you mean, the pelt rack, the beaver pelt, the weasel pelt, the mink pelt, the coyote pelt, the raccoon pelt, the wolf pelt or the unknown pelt?

>take pelts
beaver pelt: Taken.
weasel pelt: Taken.
mink pelt: Taken.
coyote pelt: Taken.
raccoon pelt: Taken.
wolf pelt: Taken.
unknown pelt: Taken.

You could of course make things even easier for the parser by just calling the pelts rack ‘a rack’ and giving it a printed name of ‘pelts rack’ or ‘pelt rack’ if you wanted.

Cottage interior is a room.

A pelt is a kind of thing.
A rack is a container in cottage interior. "Many pelts hang from a rack on the wall." The printed name of the rack is "pelts rack".
The beaver pelt, the weasel pelt, the mink pelt, the coyote pelt, the raccoon pelt, the wolf pelt, and an unknown pelt are pelts in the rack. 
Cottage interior
Many pelts hang from a rack on the wall.

>x pelts
You can't use multiple objects with that verb.

>x rack
In the pelts rack are a beaver pelt, a weasel pelt, a mink pelt, a coyote pelt, a raccoon pelt, a wolf pelt and an unknown pelt.

>x pelt
Which do you mean, the beaver pelt, the weasel pelt, the mink pelt, the coyote pelt, the raccoon pelt, the wolf pelt or the unknown pelt?

>take pelt
Which do you mean, the beaver pelt, the weasel pelt, the mink pelt, the coyote pelt, the raccoon pelt, the wolf pelt or the unknown pelt?

>take pelts
beaver pelt: Taken.
weasel pelt: Taken.
mink pelt: Taken.
coyote pelt: Taken.
raccoon pelt: Taken.
wolf pelt: Taken.
unknown pelt: Taken.

PS You’ll still need to fix the description of the rack when some or all of the pelts are taken. You probably also want to make it fixed in place.

3 Likes

I might do things like this:


A pelt is a kind of thing.
A pelt is always privately-named.
The description of a pelt is usually "Usual fur, not particularly valuable.".

Cottage interior is a room.
the  player is in cottage interior.
The pelt rack is a fixed in place container. "Many pelts hang from the wall."
The pelt rack is in cottage interior.

Some pelts are defined by the Table of Pelt Definition.

Table of Pelt Definition
pelt    description
beaver pelt "It'll make a great hat."
mink pelt   "Now that is a valuable find!"
raccoon pelt    "That'll make a great hat!"
wolf pelt   "You might be able to sell that to a shaman."
unknown pelt    "You've never seen this kind of fur before. It is exceedingly strange and smells funny."

The weasel pelt is a pelt.
The coyote pelt is a pelt.

All pelts are in the pelt rack.

Understand "pelts" as the pelt rack.
Understand "wolf"  and "pelt" as the wolf pelt.
Understand "beaver"  and "pelt" as the beaver pelt.
Understand "weasel"  and "pelt" as the weasel pelt.
Understand "mink"  and "pelt" as the mink pelt.
Understand "coyote"  and "pelt" as the coyote pelt.
Understand "raccoon"  and "pelt" as the raccoon pelt.
Understand "unknown"  and "pelt" as the  unknown pelt.

By making the pelt kind always privately-named, “pelts” doesn’t get auto-understood as meaning them. The price is that nothing else is either and you have to provide explicit understanding lines, like I did above. Of course, now “drop pelts” won’t work either.

Nor does ‘take pelts’-or at least not as the player intended it…

The pelt rack was just a contrivance to try to group the pelts together, right?

How about forget privately-named and

before listing contents: group pelts together.

Pelts-examination is an action requiring light.
Understand "examine pelts" as pelts-examination when the location is the cottage interior and the number of pelts held by the cottage interior > 1.
Understand "look at pelts" as pelts-examination when the location is the cottage interior and the number of pelts held by the cottage interior > 1.
carry out pelts-examination: say "Pelts hang from the wall." ;

Doing it like that instead of modifying the command guarantees you automatically pick up examine’s aliases. (“look at” isn’t a straight-up alias like the others so it needed its own separate line.)

Now there’s still a “can’t use multiple objects” message if you try to examine pelts under any other circumstances than being in the cottage interior and there being at least two pelts contained by the cottage. But there’s no interference with using pelts with get, drop, etc.

1 Like

Not sure about that. Based on what went before, I think perhaps it was a means of suppressing them from being listed in the room description?

I think the fundamental challenge not yet entirely answered here is finding a neat and robust way to make some actions on ‘pelts’ (examine, search, look under, and possibly a few more- and all the possible typed commands that lead to them, including chained commands) apply to one object, while leaving all other actions on ‘pelts’ to apply to a group of individual objects called ‘pelt’.

Just to mention another possibility, one could also add a grammar line for examining to let it recognize multiple objects:

Understand "examine [things]" as examining.

This automatically also takes care of “x/watch/describe/check …” and has no problems with articles like “the pelts” and so on.

It does not cover “look/l at …” and “look/l …”. For these, we can add:

Understand "look at [things]" as examining.
Understand "look [things]" as examining.

(I assume that, for the given example, we don’t need to add:
Understand "read [things]" as examining.)

Cf. example 294, Shawn’s Bad Day, in 6.15. Actions on Multiple Objects.

So, here’s a version without the rack, but with grouping (anywhere: in room descriptions, containers, and inventory), and with multiple examining and searching. Of course, it might have other issues/drawbacks.

The Cottage Interior is a room.

A pelt is a kind of thing.

The beaver pelt, weasel pelt, mink pelt, coyote pelt, raccoon pelt, wolf pelt, and an unknown pelt are pelts in the cottage interior.
	
Before listing contents: group pelts together. 
Rule for grouping together pelts: say "various pelts".

Understand "examine [things]" as examining.
Understand "look at [things]" as examining.
Understand "look [things]" as examining.

Understand "look under [things]" as looking under.

Understand "search [things]" as searching.
Understand "look inside/in/into/through [things]" as searching.

Instead of examining a pelt:
	if noun is: 
	-- beaver: say "It'll make a great hat."; 
	-- mink: say "Now that is a valuable find!";
	-- raccoon: say "That'll make a great hat!";
	-- wolf: say "You might be able to sell that to a shaman.";
	-- unknown: say "You've never seen this kind of fur before. It is exceedingly strange and smells funny.";
	-- otherwise:
		say "Usual fur, not particularly valuable.";
		
Test me with "x pelts / search pelts / look in pelts / l under pelts / get wolf / i / look / l pelts / l at pelts / get pelts / i".

Output:

Cottage Interior
You can see various pelts here.

>test me
(Testing.)

>[1] x pelts
beaver pelt: It'll make a great hat.
weasel pelt: Usual fur, not particularly valuable.
mink pelt: Now that is a valuable find!
coyote pelt: Usual fur, not particularly valuable.
raccoon pelt: That'll make a great hat!
wolf pelt: You might be able to sell that to a shaman.
unknown pelt: You've never seen this kind of fur before. It is exceedingly strange and smells funny.

>[2] search pelts
beaver pelt: You find nothing of interest.
weasel pelt: You find nothing of interest.
mink pelt: You find nothing of interest.
coyote pelt: You find nothing of interest.
raccoon pelt: You find nothing of interest.
wolf pelt: You find nothing of interest.
unknown pelt: You find nothing of interest.

>[3] look in pelts
beaver pelt: You find nothing of interest.
weasel pelt: You find nothing of interest.
mink pelt: You find nothing of interest.
coyote pelt: You find nothing of interest.
raccoon pelt: You find nothing of interest.
wolf pelt: You find nothing of interest.
unknown pelt: You find nothing of interest.

>[4] l under pelts
beaver pelt: You find nothing of interest.

weasel pelt: You find nothing of interest.

mink pelt: You find nothing of interest.

coyote pelt: You find nothing of interest.

raccoon pelt: You find nothing of interest.

wolf pelt: You find nothing of interest.

unknown pelt: You find nothing of interest.

>[5] get wolf
Taken.

>[6] i
You are carrying:
  wolf pelt

>[7] look
Cottage Interior
You can see various pelts here.

>[8] l pelts
wolf pelt: You might be able to sell that to a shaman.
beaver pelt: It'll make a great hat.
weasel pelt: Usual fur, not particularly valuable.
mink pelt: Now that is a valuable find!
coyote pelt: Usual fur, not particularly valuable.
raccoon pelt: That'll make a great hat!
unknown pelt: You've never seen this kind of fur before. It is exceedingly strange and smells funny.

>[9] l at pelts
wolf pelt: You might be able to sell that to a shaman.
beaver pelt: It'll make a great hat.
weasel pelt: Usual fur, not particularly valuable.
mink pelt: Now that is a valuable find!
coyote pelt: Usual fur, not particularly valuable.
raccoon pelt: That'll make a great hat!
unknown pelt: You've never seen this kind of fur before. It is exceedingly strange and smells funny.

>[10] get pelts
beaver pelt: Taken.
weasel pelt: Taken.
mink pelt: Taken.
coyote pelt: Taken.
raccoon pelt: Taken.
unknown pelt: Taken.

>[11] i
You are carrying:
  various pelts

Whether it’s desirable to allow the multiple actions to go through like that, is in the end up to the author.
If we’d rather have a special output for “x pelts”, then we could try to adapt the technique from example 328: “Western Art History 305”; or, with more machinery and overhead, example 295: “The Left Hand of Autumn”.

3 Likes

I thought my method answered that challenge. (Just call the pelt kind something else, so that its plural doesn’t cause a clash.)

Cottage interior is a room.

The grounds keeper is a man. The printed name of the grounds keeper is "Joe".

An animal_pelt is a kind of thing. 
Pelts are scenery in cottage interior.
The mink pelt, beaver pelt, weasel pelt, coyote pelt, raccoon pelt, wolf pelt, and an unknown pelt are animal_pelts in cottage interior.

Description of pelts is "[description of trapper] [description of pelt sequence]".
Description of trapper is "[first time][printed name of grounds keeper in sentence case] was an ardent trapper.[only]".
Description of pelt sequence is "You see a [one of]beaver [or]mink [or] weasel [or]coyote [or] raccoon [or]wolf [or]er...ah...some other unknown kind of[stopping]pelt on the wall, among others.".
	
Instead of examining an animal_pelt:
	if noun is: 
		-- beaver: say "It'll make a great hat.";
		-- mink: say "Now that is a valuable find!";
		-- otherwise:
			say "Usual fur, not particularly valuable.";

test peltz with "x pelts/ x beaver pelt/ x pelts/ x mink".

Of course, if you want some player’s commands on “pelts” to target individual pelts rather than the pelts object, that is easy to arrange with instead rules. No need for parser hacks.

Yes, that’s also what I suggested as a good solution in my original post,

but

Not entirely straightforward, because you need to somehow invoke the entire choose multiple objects-> feed them into multiple actions machinery? You can’t just write, for example try taking pelts- try...ing ... can only invoke a single action.

seems to fully deal with the problem, though- well spotted

Sorry, I didn’t notice you’d suggested that too (in my defence, it was in your Edit 3…)

Wow! This is so much more than I expected! I guess the worms got out of the can. I was trying to make the solution as simple as I could without offputting the player with the jarring default responses.
It seems though, that many Understand redefinitions is like challenging the parser again, but in a different way; e.g.,
Understand “examine [things]” as examining.
Understand “look at [things]” as examining.
Understand “look [things]” as examining.

I could rewrite all the rules this way too, couldn’t I?

So many things don’t have a simple answer. :grinning: One could do

Fooing is an action applying to nothing.
Understand the commands "examine", "x", "watch", "describe", "check" as something new.
Understand "examine" as fooing.
Understand the commands "x", "watch", "describe" and "check" as "examine".

(and as noted above, the look, look at, read cases would require further tweaking.) And then keep going replacing things as long as one wanted.

But if you were really dedicated to nuking existing meanings, all of the Standard Rules’ commands are in one place so you could do (this could be in story source, though the docs only talk about doing such a replacement in the context of doing it in another extension):

Part We don't need no standards (in place of Part Six - Grammar in Standard Rules by Graham Nelson)
[ that's for 10.1, header names were different in 9.3 ]

The understand token a time period translates into Inter as "RELATIVE_TIME_TOKEN". [ solitary non-understand line from that part ]

Book Next Part because there's no other way to say End Part except starting a new section at current or higher level

but directions aren’t commands, per se. They’re objects that the parser gives special treatment to. I said all the Standard Rules’ commands were defined in that part, but the directions’ Understand lines are elsewhere.

Likewise, “oops”, “undo”, and “again”, aka “g”, are things that look like commands to the player but are parser special-cases and can’t just be replaced like a regular command. Trying to eliminate or get different behavior out of any of them (other than the built-in Undo customization options, of course) would require Inform 6 hacking of the parser, if I recall correctly… haven’t looked at those bits lately.

I think perhaps there’s a moral to be discerned in this convoluted thread: In the end, the answer’s nearly always in the docs… if you can but find it :slight_smile:

2 Likes

Absolutely! That is my biggest general problem. Somethings the doc starts on a topic but by the bottom of the page, its talking about something different.
Thanks for your guidance.

I certainly don’t want to nuke the Standard Rules, as you put it. I want to know them well enough to rely on them with some predictability.
Thanks.

Sorry, didn’t mean to imply anything of the sort! I should’ve said “if one were really dedicated to”. Understanding how one would do it is useful to one’s understanding of how things work, even if one never wants to, which is why I went into it. (Sometimes I think about nuking the Standard Rules, but when it comes to code I’m prone to kicking over anthills.)