Setting search scope in ZIL

I wrote this in the “Recreating Zork 285”:

FIND limits search scope for GWIM to specific attribute flag
 
Search flag options:
Bit 0
    1   HAVE		Object must be in inventory
    2   MANY		Object can be multiple objects
    3   TAKE		Try to take object
    4   ON-GROUND	Set search scope for GWIM to objects at rooms top-level*
    5   IN-ROOM		Set search scope for GWIM recursively to all open containers on ground*
    6   CARRIED		Set search scope for FWIM recursively to all open containers in inventory*
    7   HELD		Set search scope for GWIM to objects at inventory top-level*
	
GWIM (Get What I Mean): If search scope narrows down to one object that meets the critera, then action is performed on that object.

* ZilLib in ZILF doesn't distinguish between HELD and CARRIED or ON-GROUND and IN-ROOM. They all search from top-level and 
  recursively in open containers in inventory or room, respectively.

Default search scope is (ON-GROUND IN-ROOM HELD CARRIED), i.e. <SYNTAX FOO OBJECT> is the same as <SYNTAX FOO OBJECT (ON-GROUND IN-ROOM HELD CARRIED)>.

This is a bit outside the scope for that because Zork 285 don’t use these flags. I nevertheless examined this a bit deeper and made a little test program on how the scope flags work.

"Example"

<VERSION XZIP>
<CONSTANT RELEASEID 1>

<CONSTANT GAME-BANNER "Search Flags test">

<ROOM ROOM1
	(DESC "Room 1")
	(NORTH TO ROOM2)
	(FLAGS LIGHTBIT)>
	
<ROOM ROOM2
	(DESC "Room 2")
	(SOUTH TO ROOM1)
	(FLAGS LIGHTBIT)>

<OBJECT ITEM1
	(IN ROOM1)
	(DESC "Item 1")
	(SYNONYM ITEM1)
	(FLAGS TAKEBIT)>
	
<OBJECT ITEM2
	(IN ROOM1)
	(DESC "Item 2")
	(SYNONYM ITEM2)
	(FLAGS TAKEBIT)>

<OBJECT ITEM3
	(IN ROOM1)
	(DESC "Item 3")
	(SYNONYM ITEM3)>

<OBJECT ITEM4
	(IN ROOM2)
	(DESC "Item 4")
	(SYNONYM ITEM4)
	(FLAGS TAKEBIT)>

<OBJECT ITEM5
	(IN ROOM2)
	(DESC "Item 5")
	(SYNONYM ITEM5)>

<ROUTINE GO () 
    <SETG HERE ,ROOM1>
    <MOVE ,PLAYER ,HERE>
    <V-LOOK>
    <MAIN-LOOP>>

<INSERT-FILE "zillib/parser">

<SYNTAX FOO OBJECT = V-FOO>
<SYNTAX FOOH OBJECT(HAVE)= V-FOO>
<SYNTAX FOOHHE OBJECT (HAVE HELD)= V-FOO>
<SYNTAX FOOHIR OBJECT (HAVE IN-ROOM)= V-FOO>
<SYNTAX FOODHHEIR OBJECT (HAVE HELD IN-ROOM) = V-FOO>
<SYNTAX FOOHE OBJECT (HELD) = V-FOO>
<SYNTAX FOOHEIR OBJECT (HELD IN-ROOM)= V-FOO>
<SYNTAX FOOIR OBJECT (IN-ROOM) = V-FOO>

<ROUTINE V-FOO () <TELL "You FOO the " D ,PRSO "." CR> <RTRUE>>

And a transcipt:

Room 1

There is a Item 1, a Item 3, and a Item 2 here.

> foo
What do you want to foo?

> get item1
You pick up the Item 1.

> foohe
[the Item 1]
You FOO the Item 1.

> fooir
What do you want to fooir?

> get item2
You pick up the Item 2.

> fooir
[the Item 3]
You FOO the Item 3.

> foohir
[the Item 3]
You aren't holding the Item 3.

> fooh
What do you want to fooh?

> drop item2
You drop the Item 2.

> fooh
What do you want to fooh?

> i
You are carrying:
   a Item 1

> foohhe
[the Item 1]
You FOO the Item 1.

> n
Room 2

There is a Item 4 and a Item 5 here.

> get item3
You don't see that here.

> get item5
That's not something you can pick up.

> get item4
You pick up the Item 4.

> s
Room 1

There is a Item 2 and a Item 3 here.

> drop all
Item 4: Dropped.
Item 1: Dropped.

> n
Room 2

There is a Item 5 here.

> foo
[the Item 5]
You FOO the Item 5.

> fooheir
[the Item 5]
You FOO the Item 5.

> foohe
What do you want to foohe?

> fooir
[the Item 5]
You FOO the Item 5.

> 

Enclosed is the compiled test. If anyone wants to experiment on their own…

sf-test.zip (12.9 KB)

It doesn’t seems fully developed in Zork 1… ATTACK has this definition:

<SYNTAX ATTACK OBJECT (FIND ACTORBIT) (ON-GROUND IN-ROOM)
	WITH OBJECT (FIND WEAPONBIT) (HELD CARRIED HAVE) = V-ATTACK>
<SYNONYM ATTACK FIGHT HURT INJURE HIT>

This would lead you to believe that the game should be able to find my sword in the inventory instead of my bare hands! (GWIM doesn’t seem to work for both PRSO and PRSI at the same time.)

>n
The Troll Room
This is a small room with passages to the east and south and a forbidding hole leading west. Bloodstains and deep scratches (perhaps made by an axe) mar the walls.
A nasty-looking troll, brandishing a bloody axe, blocks all passages out of the room.
Your sword has begun to glow very brightly.
The axe gets you right in the side. Ouch!

>attack
(troll)
Trying to attack a troll with your bare hands is suicidal.
The troll hits you with a glancing blow, and you are momentarily stunned.

>attack troll
(with the sword)
You are still recovering from that last blow, so your attack is ineffective.
The troll hits you with a glancing blow, and you are momentarily stunned.

>

I’ve added these lines to Zork 1, just to examine it a bit further:

<SYNTAX FOOBAR OBJECT (FIND ACTORBIT) (ON-GROUND IN-ROOM) WITH OBJECT (FIND WEAPONBIT) (HAVE TAKE HELD CARRIED ON-GROUND IN-ROOM) = V-FOOBAR>
<ROUTINE V-FOOBAR () <TELL "You FOOBAR the " D ,PRSO " with the " D ,PRSI "." CR> <RTRUE>>

But Zork 1 still can’t handle it as I expected:

>n
The Troll Room
This is a small room with passages to the east and south and a forbidding hole leading west. Bloodstains and deep scratches (perhaps made by an axe) mar the walls.
A nasty-looking troll, brandishing a bloody axe, blocks all passages out of the room.
Your sword has begun to glow very brightly.

>foobar
(troll)
You FOOBAR the troll with the s   ejj.

>foobar troll
What do you want to foobar the troll with?

>get sword
You already have that!
The axe gets you right in the side. Ouch!

>foobar troll with sword
You FOOBAR the troll with the sword.
The troll's axe barely misses your ear.

>

In ZILF it works as expected:

Room 1

There is a Item 1, a Item 3, and a Item 2 here.

> n
Room 2

There is a Item 4 and a Item 5 here.

> foobar
[the Item 5]
[with the Item 4]
[taking the Item 4]
You FOOBAR the Item 5 with the Item 4.

> 

I vaguely remember looking at a bug in Trinity and reaching the tentative conclusion that Infocom games in general can infer the direct object or indirect object, but not both for the same command. I don’t know if what I wrote there provides you with any leads.

1 Like

Interesting! I thought of trying it in Trinity, but it seems the “bug” is consistent over many games. Backporting the “Beyond Zork” to “Zork 1” won’t fix it. So I guess one would need to rewrite SYNTAX-CHECK more to get it to function. Maybe it’s easier to just accept that in Infocom you can’t infer both PRSO and PRSI at the same time.