Disambiguation between "all" and enumerated objects

Sorry for being a nuisance, still going around my harvesting piece of code. I’ve actually got it all working very well, thanks chiefly to Matt, Juhana and the new way in which Inform indexes phrases. I’ve just stumbled upon a slight hiccup which I’d, nevertheless, like fixed.

The problem is that disambiguation - yes, again it’s disambiguation - seems to behave as expected when I type “harvest all”, but not so well when I type “harvest grain and potatoes.” Here’s full working code which summarizes my harvesting scenario:

[code]“Test”

Unharvested food is a kind of thing. Unharvested food is always fixed in place.

Field is a room. Some grain_scenery is unharvested food in Field. Some potatoes are unharvested food in Field. Field has a number called unharvested grain. The unharvested grain of Field is 16. Field has a number called unharvested potatoes. The unharvested potatoes of Field is 8. The grain_scenery is privately-named. The printed name of the grain_scenery is “grain”. Understand “grain” as the grain_scenery.

A bag of potatoes is a kind of thing. The plural of bag of potatoes is bags of potatoes. There are 8 bags of potatoes.

A bag of grain is a kind of thing. The plural of bag of grain is bags of grain. There are 16 bags of grain.

Instead of harvesting grain_scenery:
if unharvested grain of Field > 0:
say “I harvest some grain.”;
now the player carries a random bag of grain that is off-stage;
decrease unharvested grain of Field by 1;
otherwise:
say “There is no more grain.”

Instead of harvesting potatoes:
if unharvested potatoes of Field > 0:
say “I harvest some taters.”;
now the player carries a random bag of potatoes that is off-stage;
decrease unharvested potatoes of Field by 1;
otherwise:
say “There are no more taters.”

Section 2 - Harvesting

Harvesting is an action applying to one visible thing. Understand “harvest [things]” as harvesting.

Check harvesting something which is not unharvested food (this is the block harvesting rule):
say “I can’t harvest that.”;
stop the action.

Rule for deciding whether all includes anything (called harvest material) while harvesting (this is the deal with ALL and HARVESTING rule):
if the harvest material is unharvested food:
it does;
otherwise:
it does not.

Does the player mean harvesting a bag of grain: it is very unlikely.
Does the player mean harvesting unharvested food: it is very likely.

Does the player mean harvesting a bag of potatoes: it is very unlikely.

Rule for clarifying the parser’s choice while harvesting:
do nothing.[/code]

Everything works perfectly, even “harvest all”, which gives the following output:

It’s simply wondrous to see it working. However, if the player happens to write it differently…

Bang! There it goes again.

Also, in my last thread I took the opportunity to ask a second, lesser question, and I’ll take the same liberty now. I wonder if anyone could tell me - I’m sure it’s in the manual, but I can’t easily find it - how to edit (i.e., get rid of) the enumeration when doing multiple things. I mean output like -

harvest all
I harvest some grain.
I harvest some taters.

Of course, if I could do it with one sentence, such as “I harvest [list of unharvested food in the location]”, it would be even better. The best I could find was “Rule for printing the name of unharvested food while harvesting” to replace it with a blank string, which of course gave the expected, laughable result:

harvest all
:I harvest some grain.
:I harvest some taters.

You’ll likely continue to suffer all these disambiguation troubles until you define all your terms/items more precisely; Inform often isn’t savvy enough to work these things out on its own. Consider the following modification of your example, which does not exhibit either the present problem or the disambiguation problem you previously posted about. Replace all your code posted here with:

[code]Unharvested food is a kind of thing. Unharvested food is always fixed in place.

Field is a room. Some grain_scenery is unharvested food in Field. Some potatoes are unharvested food in Field. Field has a number called unharvested grain. The unharvested grain of Field is 16. Field has a number called unharvested potatoes. The unharvested potatoes of Field is 8. The grain_scenery is privately-named. The printed name of the grain_scenery is “grain”. Understand “grain” as the grain_scenery.

A potatobag is a kind of thing. The printed name of a potatobag is “bag of potatoes”. The printed plural name of a potatobag is “bags of potatoes”. Understand “bag of potatoes” as a potatobag. Understand “bags of potatoes” as the plural of a potatobag. There are 8 potatobags.

A grainbag is a kind of thing. The printed name of a grainbag is “bag of grain”. The printed plural name of a grainbag is “bags of grain”. Understand “bag of grain” as a grainbag. Understand “bags of grain” as the plural of a grainbag. There are 16 grainbags.

Instead of harvesting grain_scenery:
if unharvested grain of Field > 0:
say “I harvest some grain.”;
now the player carries a random off-stage grainbag;
decrease unharvested grain of Field by 1;
otherwise:
say “There is no more grain.”

Instead of harvesting potatoes:
if unharvested potatoes of Field > 0:
say “I harvest some taters.”;
now the player carries a random off-stage potatobag;
decrease unharvested potatoes of Field by 1;
otherwise:
say “There are no more taters.”

Section 2 - Harvesting

Harvesting is an action applying to one visible thing. Understand “harvest [things]” as harvesting.

Check harvesting something which is not unharvested food (this is the block harvesting rule):
say “I can’t harvest that.”;
stop the action.

Rule for deciding whether all includes anything (called harvest material) while harvesting (this is the deal with ALL and HARVESTING rule):
if the harvest material is unharvested food:
it does;
otherwise:
it does not.

Does the player mean harvesting something enclosed by the player: it is very unlikely.

Rule for clarifying the parser’s choice while harvesting:
do nothing.[/code]

Regarding your second question, the underlying trouble is that 'harvest grain and potatoes" is considered by Inform to be two separate action requests (hence the individual reports, even though they are displayed on the same turn of the test game). The complexities to be considered in a rewriting of this behavior of the Standard Rules is likely why you received no response at all to your second question despite asking it several times.

So essentially, change “bag of X” to “Xbag”… well, thank you for your reply, but I have to say it saddens me a bit that I have to do something “hacky” like that. Inform is supposed not to need such “hackery” for such cases - a “bag of potatoes” is not a “bag of grain” and it’s not “potatoes” or “grain”, and I defined the grain as grain_scenery precisely to avoid such problems, but defining “potatoes” showed me that Inform could cope. And it coped all the way through, until I tried something more obscure, and was all the time left wondering why it was working one way and not working the other way. Most disheartening. Would it be worth a bug report?

Re: the second question, thank you. The question I’d asked in the previous post was another one, and it was very politely answered. This was another question altogether, and your reply is enlightening. Would it be worth a feature request to make this behaviour more easily adaptable? I understand it’s not oft-used, but Inform prides itself of the author being able to customize everything… and here’s something that doesn’t lend itself to customizing.

Slightly less hacky solution:

[code]“Test”

Unharvested food is a kind of thing. Unharvested food is always fixed in place.

Field is a room. Some grain_scenery is unharvested food in Field. Some potatoes are unharvested food in Field. Field has a number called unharvested grain. The unharvested grain of Field is 16. Field has a number called unharvested potatoes. The unharvested potatoes of Field is 8. The grain_scenery is privately-named. The printed name of the grain_scenery is “grain”. Understand “grain” as the grain_scenery.

A bag of potatoes is a kind of thing. The plural of bag of potatoes is bags of potatoes. There are 8 bags of potatoes.

A bag of potatoes is privately-named. Understand “bag of potatoes” as a bag of potatoes. Understand “potatoes/potato” as a bag of potatoes when the potatoes are not visible.

A bag of grain is a kind of thing. The plural of bag of grain is bags of grain. There are 16 bags of grain.

A bag of grain is privately-named. Understand “bag of grain” as a bag of grain. Understand “grain” as a bag of grain when the grain_scenery is not visible.

Instead of harvesting grain_scenery:
if unharvested grain of Field > 0:
say “I harvest some grain.”;
now the player carries a random bag of grain that is off-stage;
decrease unharvested grain of Field by 1;
otherwise:
say “There is no more grain.”

Instead of harvesting potatoes:
if unharvested potatoes of Field > 0:
say “I harvest some taters.”;
now the player carries a random bag of potatoes that is off-stage;
decrease unharvested potatoes of Field by 1;
otherwise:
say “There are no more taters.”

Section 2 - Harvesting

Harvesting is an action applying to one visible thing. Understand “harvest [things]” as harvesting.

Check harvesting something which is not unharvested food (this is the block harvesting rule):
say “I can’t harvest that.”;
stop the action.

Rule for deciding whether all includes anything (called harvest material) while harvesting (this is the deal with ALL and HARVESTING rule):
if the harvest material is unharvested food:
it does;
otherwise:
it does not.

Does the player mean harvesting a bag of grain: it is very unlikely.
Does the player mean harvesting unharvested food: it is very likely.
Does the player mean harvesting a bag of potatoes: it is very unlikely.

Rule for clarifying the parser’s choice while harvesting:
do nothing.[/code]

That said, I’m not sure why the Does the player mean… rules are not handling this situation correctly, and that is something that might be worthy of report.

On your second question: this is tricky, but not completely impossible. The thing to watch out for is the case where the game can’t harvest one of the items; it’s challenging to make a set of report rules flexible enough that they will account for some arbitrary members of the group being disallowed, if for instance the player typed >HARVEST GRAIN AND POTATOES AND MARIE CURIE.

Several examples treat multiple-object action reporting. You will find them in the Recipe Book under Commands > Actions on Multiple Objects.

Thank you very much. I’ve corrected it according to your suggestions, and I’m checking out the extension. Thank you all for your input.