treating two objects as one - sometimes

I have a location which contains two path objects, leading in different directions. Fictionally, they are a single object, and I want them to be treated as a single object for most commands. However, for travel commands such as FOLLOW and TAKE, they need to be treated as a separate objects, since they lead to different destinations. So, for instance, X PATH should simply give the description of either path, without disambiguation, but FOLLOW PATH should ask which path the player means.

I tried giving them an isEquivalent method which returns nil if the current action is a travel-type action, and true otherwise. But even though the method appears to be returning the correct result, the game is now treating them as equivalent for all actions. Can anyone tell me what is wrong with my code, or suggest a better alternative approach?

[code]/* Make the two middle parts of the path equivalent. /
class PathMiddle: Fixture
/

* treat the middle two paths as equivalent unless trying to travel by
* one of them
*/
isEquivalent()
{
if (gActionIn(Enter, Follow, GoThrough, Take, LookThrough, TravelVia))
{
return nil;
}
return true;
}
;

/*

  • By default, equivalence checks the name of the items as well as

  • isEquivalent. For the middle paths, skip that bit.
    */
    modify basicDistinguisher
    canDistinguish(a, b)
    {
    if (a.ofKind(PathMiddle) && b.ofKind(PathMiddle))
    {
    return !(a.isEquivalent && b.isEquivalent);
    }

    return inherited(a, b);
    }
    ;

  • gardenPathN: PathMiddle
    ‘north n path (to) (the) n/north/path’
    ‘path to the north’
    ;

  • gardenPathS: PathMiddle
    ‘south s path (to) (the) south/s/path’
    ‘path to the south’
    ;[/code]
    (In my actual code, PathMiddle is a subclass of PathPassage, which handles all the travel-related code, but I’ve made it a fixture here to make the code easier to run on its own.)

I wrestle for days with this problem, then finally swallow my pride and ask for help - and, of course, within quarter of an hour of posting I realise what I was doing wrong.

Earlier, I approached the problem by adding a third object to represent the path as a whole, but I couldn’t quite get that to work the way I wanted it to. I was using verify to make it more likely than the other paths, and that borked a whole lot of other library stuff that was handled in the verify phase.

It turns out I had the right idea back then, but the wrong implementation. Instead of fiddling around with verify, I only had to increase the vocabLikelihood of the path-as-a-whole object. Behold!

[code]+ gardenPathAmbig: PathPassage, AskConnector
‘path’
‘path’

/* ask about the other two ends of the path */
travelAction = FollowAction
travelObjs = [gardenPathS, gardenPathNE]

askDisambig(targetActor, promptTxt, curMatchList, 
            fullMatchList, requiredNum, askingAgain, dist)
{
    "The path leads in two directions from here. Which way do
    you want to go, north to the cubby house or southwest to
    the front garden? ";
}

/* 
 *   more likely than the other two paths, if the player doesn't mention 
 *   a specific path
 */
vocabLikelihood = 50

;[/code]

Nice - I did not know about the vocabLikelihood property. Very handy!