disambiguation problem (adv3Lite)

There are three kinds of food pouches available in the galley—steak, potatoes, and vegetables. In order to eat them, the PC must properly prepare them, a process which begins with adding water to rehydrate.

To implement this scenario, I have defined a FoodPouch class with three subclasses, one for each of the different food types. The primary noun for each of the classes is ‘pouch’ and each class is further disambiguated by a disambigName = ’ pouch’

class FoodPouch: Thing vocabWords = 'pouch;food;package' disambigName = 'food pouch' ; class VegPouch: FoodPouch 'pouch;medley vegetable veg veggie;packet package' disambigName = 'vegetable pouch' ; class SteakPouch: FoodPouch 'pouch;filet mignon steak;packet' disambigName = 'steak pouch' ; class PotatoPouch: FoodPouch 'pouch;scalloped potato potatoe;packet package' disambigName = 'potato pouch' ;

I have defined an AddTo verb and a ‘water’ object, so the first step in preparing the food for eating is the command add water to pouch.

// add VerbRule(AddTo) 'add' singleDobj 'to' singleIobj : VerbProduction action = AddTo verbPhrase = 'add/adding (what) (to what)' missingQ = 'What do you want to add;what do you want to add it to' ; DefineTIAction(AddTo) resolveIobjFirst = true ;

There can be more than one pouch in scope at a time.

If there are multiple pouches in scope, the command add water to pouches produces, as it should, a request to disambiguate.

But the parser does not recognize the dismabigName property of the object I’m carrying until I force some kind of update action by issuing an intermediate command.

This produces the following confusion (I’m carrying a steak pouch and a potato pouch; a vegetable pouch is also in scope)…

I need to find some way to force the disambiguation update in the code, not on the command line, so that the pouch I am carrying is identified by its disambigName property the first time I enter the add water command.

But where?

I can’t find a hook that will let me force the update. A breakpoint in check() for iobjFor(AddTo) doesn’t stop the action until after the disambiguated name is entered on the command line.

Jerry

Untested, but have you tried adding the adjective as part of the name for each of your subclasses, along these lines?

class SteakPouch: FoodPouch 'steak pouch;filet mignon;packet' ;

I have. In fact, that’s what I started with when I first implemented these classes, but during the course of implementation, the code evolved to not elevating the adjective into the noun position of the vocab property.

There are multiple references to these pouches and sometimes it is awkward to use the fully qualified name. Sometimes, I need to just say “the pouch.” As I said, this code has evolved over many iterations and the current implementation is the winner of many beauty contests.

If I have to go back and rework what amounts to a substantial amount of code to make this work, well, so be it, I guess, for lack of an alternative.

But I would much rather find a way to make disambiguation work.

Jerry

Since Eric is out of town, I thought I’d try it myself. After working my way through a couple of user errors, I seem to have it working. Here’s my code (omitting gameMain):

[code]Test ‘pouches’ [‘s’, ‘take veggie pouch’, ‘take potato pouch’, ‘take steak pouch’,
‘n’, ‘i’, ‘drop potato pouch’, ‘i’, ‘l’, ‘add water to pouch’, ‘vegetable’, ‘drop steak pouch’, ‘l’, ‘i’];

VerbRule(AddTo)
‘add’ singleDobj ‘to’ singleIobj
: VerbProduction
action = AddTo
verbPhrase = ‘add/adding (what) (to what)’
missingQ = ‘What do you want to add;what do you want to add it to’
;
DefineTIAction(AddTo)
resolveIobjFirst = true
;

mainRoom: Room ‘Main Room’
"This handsomely appointed room is now quite bare, although a river runs
through it. The pantry is to the south. "

south = pantry

;

  • river: Fixture ‘water; flowing running wet; river’
    "The river is composed of water, and is noticeably wet. "
    dobjFor(AddTo) {
    verify() {}
    check() {
    if (!gIobj.ofKind(FoodPouch)) "You can’t add water to that! ";
    }
    }
    ;

  • me: Thing ‘you’
    isFixed = true
    person = 2
    contType = Carrier
    ;

pantry: Room ‘Pantry’
"A well-stocked pantry. "
north = mainRoom
;

  • SteakPouch;
  • SteakPouch;
  • PotatoPouch;
  • PotatoPouch;
  • VeggiePouch;
  • VeggiePouch;

class FoodPouch: Thing
// vocabWords = ‘pouch;food;package’
// disambigName = ‘food pouch’
iobjFor(AddTo) {
verify() {}
check() {
if (gDobj != river) "You can’t add that to the pouch! ";
}
action() {
"We are now adding water to the food pouch. ";
}
}
;
class SteakPouch: FoodPouch ‘steak pouch;filet mignon;packet package’
"The pouch contains steak. "
// disambigName = ‘steak pouch’
;
class PotatoPouch: FoodPouch ‘potato pouch;scalloped potatoe;packet
package spuds’
"The pouch contains spuds. "
// disambigName = ‘potato pouch’
;
class VeggiePouch: FoodPouch ‘vegetable pouch; veggie veg; packet package veggies’
"The pouch contains vegetables. "
// disambigName = ‘vegetable pouch’
;[/code]
And here’s the output:

It seems not to be malfunctioning. My suspicion is that maybe you’ve duplicated some code somewhere and aren’t editing the bit that you think you’re editing.

Thanks for the effort, but it doesn’t solve the problem I’m seeing.

I can get the same results just by adding “steak”, “potato”, and “vegetable” to the vocab properties of the FoodPouch subclasses. When i do that, I get correct results, without any of your additional coding.

The problem I’m trying to solve is the timing of the parser’s switch from name to disambigName when I do not include the adjective (“steak”, “potato”, or “vegetable”) in the noun position of the vocab property. (All three are defined only as “pouch” with the adjectives in the adjective slot of the vocab property)

The game code is asking me what do I want to add water to, “the pouch, the steak pouch or the vegetable pouch” instead of going to the disambigName for that first pouch in the list.

The parser does make the switch, but not until I push it by checking inventory on the command line. It’s supposed to make the switch to disambigName internally, under the covers, in code.

That’s the bit I want to trigger—the use of disambigName when there is an ambiguity to dis.

(BTW, the reason I created a FoodPouch class with subclasses rather than hardcoding food pouch objects as you did is so that I can have an unlimited supply. Player has to properly prepare and eat one of each kind of food. If the pouch is prepared incorrectly, it is inedible and must be discarded, then another pouch obtained, over and over ad nauseam until the meal is complete.)