EXAMINE disambiguation

In both Inform and TADS, the EXAMINE verb will, all else being equal, prefer an item carried by the PC. So if you’re holding a blue book and you walk into a room that contains a green book, X BOOK will automatically choose the blue book you’re carrying, rather than choosing the green book that you’ve just encountered or asking “Which book do you mean, the blue book or the green book?”

This has never made much sense to me, but since both Inform and TADS do it this way, I figure must be some (historical?) reason for it. Just curious if anyone knows what the rationale is/was? Is it an inheritance from Infocom, and if so, do we know why they chose to do it that way?

This is just a guess, but it makes some sense that you’re more likely to interact more often with a thing you’re carrying. So if you’ve used to doing >LOOK UP x IN BOOK everywhere, then the same command should work identically even when you go into a room that has another book.

Right, and that’s the reason for Inform’s general rule on disambiguation.

It then has special behavior for some verbs (mostly TAKE) which prefer things you’re not carrying. That’s obvious. But there is no such special behavior for EXAMINE; that follows the general rule. You can argue that one either way.

Well, sometimes I want the one, sometimes the other.

Yes, it’s tricky. Usually it’s OBVIOUS that I want to examine the item in the room I’ve just entered, because I want to take a look at it.

Other times it’s OBVIOUS that I want to examine what I’m holding, because everything else has been examined.

…now that I actually come to write this, does the disambiguation rule for “examine” take into account whether the item has already been examined?

Pretty sure not. The desirable behavior would be that you examine something that hasn’t been examined, unless something just happened to something you’ve already examined that changes the description, or it’s been a while since you examined something so you want to refresh your memory… it’s tricky enough that you can see why it’s not implemented this way in the standard rules. I did just about get it to work the way I wanted with Does The Player Mean rules, which was surprising because I never get DTPM rules to work the way I want:

[spoiler][code]Hangar 51 is a room. The player carries a box cutter. The description of the box cutter is “[one of]Oh! The intro text forgot to mention the box cutter you started with. It might be important[or]When you’re holding this box cutter you can cut a box. (You don’t have to type CUT BOX WITH BOX CUTTER)[stopping].”

A large box is in Hangar 51. “The only interesting thing here is a large box.” The description of the large box is “It looks interesting, and [if closed]tightly sealed[otherwise]invitingly searchable[end if].”

A thing can be examined or unexamined. A thing is usually unexamined.
Carry out examining: now the noun is examined.
Does the player mean examining an unexamined thing: It is likely.
Does the player mean cutting the large box: it is very likely.
The large box can be open. The large box is closed. The large box can be openable. The large box is unopenable.

Check cutting the large box when the player does not hold the box cutter: say “You’ll need a box cutter to do that.” instead.
Check cutting the open large box: say “You’ve already cut it open.”
The block cutting rule does nothing when the noun is the large box.
Carry out cutting the large box:
now the large box is open;
now the large box is unexamined.
Report cutting the large box: say “You cut away the seals. You can’t wait to search it!”

The can’t search unless container or supporter rule does nothing when the noun is the large box.
Does the player mean searching the large box: it is very likely.
Instead of searching or opening the closed large box: say “It’s tightly sealed.”
Instead of searching the open large box:
end the story finally saying “It’s the ark!”.

Test me with “x box/x box/x box/cut box/x box/x box/search box”.[/code][/spoiler]

Note the subtle product placement for a popular (?) videogame console.

EDIT: Forgot this wasn’t specifically an Inform 7 discussion, but maybe this transfers easily to TADS…

That’s interesting, I hadn’t realised. In TADS it’s defined specifically on the EXAMINE verb (but then, in TADS it’s hard to make disambiguation rules apply to more than one action).

Yeah, I think my preferred behaviour is for the game to just ask every time, rather than trying to guess. That’s easy to achieve in TADS, at least.

That seems like a job for “Does the player mean examining something examined: it is unlikely.”

If you just idly examine something, the one you’re holding will probably come into scope first. Unless it’s sunglasses on your head you’ve been looking for all day.