Thursday, 14 June 2018

ZILF Library Accumulated Updates

I'm now keeping a copy of the latest state of the ZILF library plus requested changes on GitHub and on Bitbucket. This will be synced with the latest state of the ZILF library in order to merge changes from all sources. The current differences are as follows.





Monday, 11 June 2018

Heidi in ZIL (The Mechanics)

Much of the mechanics of a game is already implemented in the library. Defining what is not already implemented in the library can be broken down into two areas.
  • Library Extensions
  • Library Overrides

All work on the mechanics of ZIL games is now based on the development version of the library, not the 0.8 release version.


Library Extensions


This refers to the situation where new syntax or behaviour is defined. Some of the definitions may be game-specific, others may be of more general use.

Heidi requires the following library extensions.

<SYNTAX ENTER = V-GO-IN>
<ROUTINE V-GO-IN () <DO-WALK ,P?IN>>

<SYNTAX LISTEN TO OBJECT (MANY HELD CARRIED ON-GROUND IN-ROOM) = V-LISTEN PRE-REQUIRES-LIGHT>
<ROUTINE V-LISTEN () <TELL "You hear nothing unexpected." CR>>



Library Overrides


This refers to the situation where existing syntax or behaviour is re-defined. Again, some of the definitions may be game-specific, others may be of more general use.

The following library override re-defines the syntax for the CLIMB command and requires that the original be put in a replacement section, hence the use of the development version of the library which can be supplemented with change requests.

<REPLACE-DEFINITION CLIMB
    <SYNTAX CLIMB OBJECT (ON-GROUND IN-ROOM) = V-CLIMB>
>


This achieves the following effect for consistency with the original game.

> climb
[the tall sycamore tree]

At the top of the tree
You cling precariously to the trunk.

There is a wide firm bough here.

>


The following library override re-defines the behaviour of V-WALK.

<REPLACE-DEFINITION V-WALK
    <ROUTINE V-WALK ("AUX" PT PTS RM THERE-LIT D)
        <COND (<NOT ,PRSO-DIR>
               <PRINTR "You must give a direction to walk in.">)
              (<0? <SET PT <GETPT ,HERE ,PRSO>>>
               <COND (<OR ,HERE-LIT <NOT <DARKNESS-F ,M-DARK-CANT-GO>>>
                      <TELL ,CANT-GO-THAT-WAY CR>)>
               <SETG P-CONT 0>
               <RTRUE>)
              (<==? <SET PTS <PTSIZE .PT>> ,UEXIT>
               <SET RM <GET/B .PT ,EXIT-RM>>)
              (<==? .PTS ,NEXIT>
               <TELL <GET .PT ,NEXIT-MSG> CR>
               <SETG P-CONT 0>
               <RTRUE>)
              (<==? .PTS ,FEXIT>
               <COND (<0? <SET RM <APPLY <GET .PT ,FEXIT-RTN>>>>
                      <SETG P-CONT 0>
                      <RTRUE>)>)
              (<==? .PTS ,CEXIT>
               <COND (<VALUE <GETB .PT ,CEXIT-VAR>>
                      <SET RM <GET/B .PT ,EXIT-RM>>)
                     (ELSE
                      <COND (<SET RM <GET .PT ,CEXIT-MSG>>
                             <TELL .RM CR>)
                            (<AND <NOT ,HERE-LIT> <DARKNESS-F ,M-DARK-CANT-GO>>
                             ;"DARKNESS-F printed a message")
                            (ELSE
                             <TELL ,CANT-GO-THAT-WAY CR>)>
                      <SETG P-CONT 0>
                      <RTRUE>)>)
              (<==? .PTS ,DEXIT>
               <COND (<FSET? <SET D <GET/B .PT ,DEXIT-OBJ>> ,OPENBIT>
                      <SET RM <GET/B .PT ,EXIT-RM>>)
                     (<SET RM <GET .PT ,DEXIT-MSG>>
                      <TELL .RM CR>
                      <SETG P-CONT 0>
                      <RTRUE>)
                     (ELSE
                      <THIS-IS-IT .D>
                      <TELL "You'll have to open " T .D
                            " first." CR>
                      <SETG P-CONT 0>
                      <RTRUE>)>)
              (ELSE
               <TELL "Broken exit (" N .PTS ")." CR>
               <SETG P-CONT 0>
               <RTRUE>)>
        <CRLF>
        <GOTO .RM>
    >
>


The only difference between this and the original is the extra <CRLF> before <GOTO .RM>. This prints a blank line before each new room description. Again, this is for consistency with the original game.

The following library override re-defines the behaviour of PRINT-GAME-OVER.

<REPLACE-DEFINITION PRINT-GAME-OVER
    <ROUTINE PRINT-GAME-OVER ()
        <RETURN>
    >
>


Now, the game relies exclusively on JIGS-UP to print end-of-game messages.

Whereas the preceeding three overrides were only about presentation, the following alters the behaviour of TAKE so that it depends, in effect, on the number of items held.

<REPLACE-DEFINITION TAKE-CAPACITY-CHECK
    <ROUTINE TAKE-CAPACITY-CHECK (O "OPT" SILENT "AUX" (CAP <GETP PLAYER ,P?CAPACITY>) CWT NWT)
        <COND (<L? .CAP 0> <RTRUE>)>
        <SET CWT <CONTENTS-WEIGHT PLAYER>>
        <SET NWT <GETP .O ,P?SIZE>>
        <COND (<G? <+ .CWT .NWT> .CAP>
            <COND
                (.SILENT)
                (<SHORT-REPORT?>
                    <TELL "You're carrying too much." CR>)
                (ELSE
                    <TELL "You're carrying too much to pick up " T .O "." CR>)>
            <RFALSE>)>
        <RTRUE>
    >
>

Saturday, 9 June 2018

Heidi in ZIL (The Story)

This puzzle dependency graph shows the single goal of the game. Finishing the game is dependent on this goal alone.


Finishing the game


The following interrupt routine checks whether or not the bird has been rescued. It is queued to run every turn at the start of the game.

<ROUTINE I-GAME-OVER ()
    <COND (<AND <IN? BIRD NEST> <IN? NEST BRANCH>>
        <CRLF> <CRLF>
        <JIGS-UP "    *** You have won ***">)>
>


Listening to the bird


The following modifications make it clear that the player should rescue the bird.

<SYNTAX LISTEN TO OBJECT (MANY HELD CARRIED ON-GROUND IN-ROOM) = V-LISTEN PRE-REQUIRES-LIGHT>
<ROUTINE V-LISTEN () <TELL "You hear nothing unexpected." CR>>

<OBJECT BIRD(LOC FOREST)(DESC "baby bird")
    (FLAGS TAKEBIT)
    (TEXT "Too young to fly, the nestling tweets helplessly.")
    (SYNONYM BIRD NESTLING)(ADJECTIVE BABY)
    (ACTION BIRD-F)
>

<ROUTINE BIRD-F ()
    <COND (<VERB? LISTEN>
        <TELL "It sounds scared and in need of assistance." CR>)>
>


Climbing the tree


The following modifications allow the player to climb the tree, as an alternative to just going up.

<REPLACE-DEFINITION CLIMB
    <SYNTAX CLIMB OBJECT (ON-GROUND IN-ROOM) = V-CLIMB>
>

<OBJECT TREE(LOC CLEARING)(DESC "tall sycamore tree")
    (FLAGS NDESCBIT)
    (TEXT "Standing proud in the middle of the clearing,
the stout tree looks easy to climb.")
    (SYNONYM TREE SYCAMORE)(ADJECTIVE TALL STOUT PROUD SYCAMORE)
    (ACTION TREE-F)
>

<ROUTINE TREE-F ()
    <COND (<VERB? CLIMB>
        <DO-WALK ,P?UP>)>
>


Dropping objects from the tree


The following modifications allow the player to drop objects from the tree, instead of the default behaviour which would drop objects at the top of the tree.

<ROOM TOP-OF-TREE(IN ROOMS)(DESC "At the top of the tree")
    (FLAGS LIGHTBIT)
    (LDESC "You cling precariously to the trunk.")
    (DOWN TO CLEARING)
    (ACTION TOP-OF-TREE-F)
>

<ROUTINE TOP-OF-TREE-F (RARG)
    <COND (<=? .RARG ,M-BEG>
        <COND (<VERB? DROP>
            <MOVE ,PRSO CLEARING>
            <TELL "Dropped... to the ground far below." CR>)>)>
>

Heidi in ZIL (The Setting)

This map shows the rooms and objects in the game.


Defining the Rooms


The following ZIL source defines the rooms, joined up as shown in the map.

<ROOM BEFORE-COTTAGE(IN ROOMS)(DESC "In front of a cottage")
    (FLAGS LIGHTBIT)
    (LDESC "You stand outside a cottage. The forest stretches east.")
    (EAST TO FOREST)
>

<ROOM FOREST(IN ROOMS)(DESC "Deep in the forest")
    (FLAGS LIGHTBIT)
    (LDESC "Through the dense foliage, you glimpse a building to the west.
A track heads to the northeast.")
    (WEST TO BEFORE-COTTAGE)
    (NE TO CLEARING)
>

<ROOM CLEARING(IN ROOMS)(DESC "A forest clearing")
    (FLAGS LIGHTBIT)
    (LDESC "A tall sycamore stands in the middle of this clearing.
The path winds southwest through the trees.")
    (SW TO FOREST)
    (UP TO TOP-OF-TREE)
>

<ROOM TOP-OF-TREE(IN ROOMS)(DESC "At the top of the tree")
    (FLAGS LIGHTBIT)
    (LDESC "You cling precariously to the trunk.")
    (DOWN TO CLEARING)
>


Adding the bird and the nest


The following ZIL source defines the bird and the nest, placed as shown in the map.

<OBJECT BIRD(LOC FOREST)(DESC "baby bird")
    (FLAGS TAKEBIT)
    (TEXT "Too young to fly, the nestling tweets helplessly.")
    (SYNONYM BIRD NESTLING)(ADJECTIVE BABY)
>

<OBJECT NEST(LOC CLEARING)(DESC "bird's nest")
    (FLAGS CONTBIT OPENBIT TAKEBIT)
    (TEXT "The nest is carefully woven of twigs and moss.")
    (SYNONYM NEST TWIGS MOSS)(ADJECTIVE BIRD\'S)
>


Adding the tree and the branch


The following ZIL source defines the tree and the branch, placed as shown in the map.

<OBJECT TREE(LOC CLEARING)(DESC "tall sycamore tree")
    (FLAGS NDESCBIT)
    (TEXT "Standing proud in the middle of the clearing,
the stout tree looks easy to climb.")
    (SYNONYM TREE SYCAMORE)(ADJECTIVE TALL STOUT PROUD SYCAMORE)
>

<OBJECT BRANCH(LOC TOP-OF-TREE)(DESC "wide firm bough")
    (FLAGS CONTBIT OPENBIT SURFACEBIT)
    (TEXT "It's flat enough to support a small object.")
    (SYNONYM BOUGH BRANCH)(ADJECTIVE WIDE FIRM FLAT)
>


Adding the Cottage


The following ZIL source defines the cottage, placed as shown in the map.

<OBJECT COTTAGE(LOC BEFORE-COTTAGE)(DESC "tiny cottage")
    (FLAGS NDESCBIT)
    (TEXT "It's small and simple, but you're very happy here.")
    (SYNONYM COTTAGE HOME HOUSE HUT SHED HOVEL)(ADJECTIVE TINY)
>


Finishing Touches


The following modifications make it clear that the player should go east.

<SYNTAX ENTER = V-GO-IN>
<ROUTINE V-GO-IN () <DO-WALK ,P?IN>>


<ROOM BEFORE-COTTAGE(IN ROOMS)(DESC "In front of a cottage")
    (FLAGS LIGHTBIT)
    (LDESC "You stand outside a cottage. The forest stretches east.")
    (EAST TO FOREST)
    (IN SORRY "It's such a lovely day -- much too nice to go inside.")
    (ACTION BEFORE-COTTAGE-F)
>

<ROUTINE BEFORE-COTTAGE-F (RARG)
    <COND (<=? .RARG ,M-BEG>
        <COND (<AND <VERB? WALK> <0? <GETPT ,HERE ,PRSO>>>
            <TELL "The only path lies to the east." CR>)>)>
>

<OBJECT COTTAGE(LOC BEFORE-COTTAGE)(DESC "tiny cottage")
    (FLAGS NDESCBIT)
    (TEXT "It's small and simple, but you're very happy here.")
    (SYNONYM COTTAGE HOME HOUSE HUT SHED HOVEL)(ADJECTIVE TINY)
    (ACTION COTTAGE-F)
>

<ROUTINE COTTAGE-F ()
    <COND (<VERB? ENTER>
        <V-GO-IN>)>
>

Saturday, 17 March 2018

Interacting with the Objects: The House


Original MDL Version


In the original MDL, responses are coded for two regions.
  1. the vicinity of the house
  2. the forest

The Vicinity of the House

"FIND"
"It's right in front of you.  Are you blind or something?"

"LKAT"
"The house is a beautiful colonial house which is painted white.
It is clear that the owners must have been extremely wealthy."

"GTHRO"
in "EHOUS" if the window is not open ...
"The window is closed."
elsewhere in the region ...
"I can't see how to get in from here."

"BURN"
"You must be joking."

The Forest

"FIND"
in "CLEAR" ...
"It seems to be to the southwest."
elsewhere in the region ...
"It was just here a minute ago...."

any other verb...
"You're not at the house."

ZIL Version


<SYNTAX FIND OBJECT (MANY HELD CARRIED ON-GROUND IN-ROOM) = V-FIND PRE-REQUIRES-LIGHT>

<SYNTAX LOOK AT OBJECT (MANY HELD CARRIED ON-GROUND IN-ROOM) = V-LOOK-AT PRE-REQUIRES-LIGHT>

<SYNTAX ENTER = V-GO-IN>

<VERB-SYNONYM ATTACK MUNG>


<ROUTINE V-FIND ()
    <V-LOOK-AT>
>

<ROUTINE V-LOOK-AT ()
    <V-EXAMINE>
>

<ROUTINE V-GO-IN ()
    <DO-WALK ,P?IN>
>


<OBJECT HOUSE(LOC LOCAL-GLOBALS)(DESC "white house")
    (FLAGS NDESCBIT)
    (SYNONYM HOUSE)(ADJECTIVE WHITE)
    (ACTION HOUSE-F)
>

<ROUTINE HOUSE-F ()
    <COND (<OR <=? ,HERE WEST-OF-HOUSE>
               <=? ,HERE NORTH-OF-HOUSE>
               <=? ,HERE SOUTH-OF-HOUSE>
               <=? ,HERE BEHIND-HOUSE>>
           <COND (<VERB? FIND>
                  <TELL "It's right in front of you.  Are you blind or something?" CR>)
                 (<VERB? LOOK-AT>
                  <TELL "The house is a beautiful colonial house which is painted white.|
It is clear that the owners must have been extremely wealthy." CR>)
                 (<VERB? ENTER>
                  <COND (<=? ,HERE BEHIND-HOUSE>
                         <COND (<FSET? WINDOW OPENBIT>
                                <DO-WALK ,P?IN>)
                               ( ELSE
                                <TELL "The window is closed." CR>)>)
                        ( ELSE
                         <TELL "I can't see how to get in from here." CR>)>)
                 (<VERB? BURN>
                  <TELL "You must be joking." CR>)>)
          (<COND (<VERB? FIND>
                  <COND (<=? ,HERE CLEARING>
                         <TELL "It seems to be to the southwest." CR>)
                        ( ELSE
                         <TELL "It was just here a minute ago...." CR>)>)
                 ( ELSE
                  <TELL "You're not at the house." CR>)>)>
>



Monday, 19 February 2018

February Update

This month, I've spent some time on ZILF library changes. I've also added placeholders for all of the rooms in the game to get a better idea of the likely size of the finished game. It still fits easily in z5. I've also done some work on the second setting in the game, the forest.


As usual, the source code can be seen by following the Learning ZIL on Bitbucket link on the right.

Monday, 29 January 2018

Extending the ZILF Library

Thanks to Jesse McGrew for the following explanation.

There are two mechanisms for replacing library code without hacking the library:
  1. Replace a definition section. For example, the DARKNESS-F routine is defined in its own section in verbs.zil, which is also named DARKNESS-F. The default is given with DEFAULT-DEFINITION, and you can replace it with REPLACE-DEFINITION. See advent.zil. The key is that you have to ask to replace the default *before* the default itself, with REPLACE-DEFINITION or at least DELAY-DEFINITION.
     
  2. Redefine a single named thing. If you define two routines with the same name, the second one will overwrite the first. Normally the compiler prevents this, but you can allow it by putting <SET REDEFINE T> somewhere above -- or equivalently, by putting your replacement(s) inside a <BIND ((REDEFINE T)) ...>, which will help avoid accidentally clobbering things you don't mean to.
 It seems to me that <BIND ((REDEFINE T)) ...> could provide a general mechanism for library extensions.


Current Library Extensions for Zork

  • libj4-bugfixes.zil (fixes problem reading the leaflet in the mailbox)
  • zork-objdesc.zil (single-spaces object descriptions)
  • zork-version.zil (prints the game title in bold for games which are not z3)

House and Vicinity: The House (Explorable Map)

The house itself consists of three rooms, organised, according to the original MDL code, like this.



Again, let's try coding the details of this map in ZIL using the original MDL code to provide the text descriptions and responses.

Kitchen


<ROOM KITCHEN(IN ROOMS)(DESC "Kitchen")
    (FLAGS LIGHTBIT)
    (EAST TO BEHIND-HOUSE IF WINDOW IS OPEN)
    (OUT TO BEHIND-HOUSE IF WINDOW IS OPEN)
    (WEST TO LIVING-ROOM)(UP TO ATTIC)
    (DOWN SORRY "Only Santa Claus climbs down chimneys.")
    (ACTION KITCHEN-F)
    (GLOBAL WINDOW)
    (VALUE 10)
>

<ROUTINE KITCHEN-F (RARG)
    <COND (<=? .RARG ,M-LOOK>
           <TELL "You are in the kitchen of the white house.  A table seems to have|
been used recently for the preparation of food.  A passage leads to|
the west and a dark staircase can be seen leading upward.  To the|
east is a small window which is ">
           <COND (<FSET? ,WINDOW OPENBIT>
                  <TELL "open." CR>)
                 ( ELSE <TELL "slightly ajar." CR>)>)>
>

<OBJECT GLASS-BOTTLE(LOC KITCHEN)(DESC "glass bottle")
    (FLAGS TAKEBIT TRANSBIT CONTBIT)
    (FDESC "A bottle is sitting on the table.")
    (LDESC "A clear glass bottle is here.")
    (SYNONYM BOTTLE CONTAINER)(ADJECTIVE CLEAR GLASS)
    (CAPACITY 4)
>

<OBJECT WATER(LOC GLASS-BOTTLE)(DESC "quantity of water")
    (FLAGS TAKEBIT)
    (LDESC "There is some water here")
    (SYNONYM WATER QUANTITY LIQUID H2O)
    (SIZE 4)
>

<OBJECT BROWN-SACK(LOC KITCHEN)(DESC "brown sack")
    (FLAGS TAKEBIT CONTBIT OPENABLEBIT BURNBIT)
    (FDESC "On the table is an elongated brown sack, smelling of hot peppers.")
    (LDESC "A brown sack is here.")
    (SYNONYM BAG SACK)(ADJECTIVE BROWN ELONGATED)
    (SIZE 3)(CAPACITY 15)
>

<OBJECT CLOVE-OF-GARLIC(LOC BROWN-SACK)(DESC "clove of garlic")
    (FLAGS TAKEBIT FOODBIT)
    (LDESC "There is a clove of garlic here.")
    (SYNONYM GARLIC CLOVE)
>

<OBJECT LUNCH(LOC BROWN-SACK)(DESC "lunch")
    (FLAGS TAKEBIT EDIBLEBIT)
    (LDESC "A hot pepper sandwich is here.")
    (SYNONYM FOOD SANDWICH LUNCH DINNER)(ADJECTIVE HOT PEPPER)
>


Attic


<ROOM ATTIC(IN ROOMS)(DESC "Attic")
    (DOWN TO KITCHEN)
    (LDESC "This is the attic.  The only exit is stairs that lead down.")
>

<OBJECT KNIFE(LOC ATTIC)(DESC "knife")
    (FLAGS TAKEBIT)
    (FDESC "On a table is a nasty-looking knife.")
    (LDESC "There is a nasty-looking knife lying here.")
    (SYNONYM KNIFE BLADE)(ADJECTIVE NASTY UNRUSTED PLAIN)
>

<OBJECT ROPE(LOC ATTIC)(DESC "rope")
    (FLAGS TAKEBIT)
    (FDESC "A large coil of rope is lying in the corner.")
    (LDESC "There is a large coil of rope here.")
    (SYNONYM ROPE HEMP COIL)(ADJECTIVE LARGE)
    (SIZE 10)
>

<OBJECT BRICK(LOC ATTIC)(DESC "brick")
    (FLAGS TAKEBIT BURNBIT OPENBIT)
    (LDESC "There is a square brick here which feels like clay.")
    (SYNONYM BRICK)(ADJECTIVE SQUARE CLAY)
    (SIZE 9)(CAPACITY 2)
>


Living Room


<GLOBAL MAGIC-FLAG <>>
<GLOBAL RUG-MOVED-FLAG <>>

<ROOM LIVING-ROOM(IN ROOMS)(DESC "Living Room")
    (FLAGS LIGHTBIT)
    (EAST TO KITCHEN)
    ;(WEST TO STRANGE-PASSAGE IF MAGIC-FLAG ELSE "The door is nailed shut.")
    (DOWN TO CELLAR IF WOODEN-DOOR IS OPEN)
    (ACTION LIVING-ROOM-F)
    (GLOBAL WOODEN-DOOR TRAP-DOOR)
>

<ROUTINE LIVING-ROOM-F (RARG)
    <COND (<=? .RARG ,M-LOOK>
           <TELL "You are in the living room.  There is a door to the east">
           <COND ( ,MAGIC-FLAG
                  <TELL ".  To the|
west is a cyclops-shaped hole in an old wooden door, above which is|
some strange gothic lettering ">)
                 ( ELSE
                  <TELL ", a wooden|
door with strange gothic lettering to the west, which appears to be|
nailed shut, ">)
           >
           <COND (<AND ,RUG-MOVED-FLAG <FSET? TRAP-DOOR OPENBIT>>
                  <TELL "and a rug lying beside an open trap-door." CR>)
                 ( ,RUG-MOVED-FLAG
                  <TELL "and a closed trap-door at your feet." CR>)
                 (<FSET? TRAP-DOOR OPENBIT>
                  <TELL "and an open trap-door at your feet." CR>)
                 ( ELSE
                  <TELL "and a large oriental rug in the center of the room." CR>)
           >
          )
    >
>

<OBJECT WOODEN-DOOR(LOC LOCAL-GLOBALS)(DESC "wooden door")
    (FLAGS READBIT DOORBIT OPENABLEBIT NDESCBIT)
    (TEXT "The engravings translate to 'This space intentionally left blank'")
    (SYNONYM DOOR)(ADJECTIVE WOODEN WEST WESTERN)
>

<OBJECT TRAP-DOOR(LOC LOCAL-GLOBALS)(DESC "trap door")
    (FLAGS DOORBIT OPENABLEBIT NDESCBIT)
    (SYNONYM DOOR TRAPDOOR TRAP-DOOR)(ADJECTIVE TRAP)
>

<OBJECT CARPET(LOC LIVING-ROOM)(DESC "carpet")
    (FLAGS NDESCBIT TRYTAKEBIT)
>

<OBJECT SWORD(LOC LIVING-ROOM)(DESC "sword")
    (FLAGS TAKEBIT)
    (FDESC  "On hooks above the mantelpiece hangs an elvish sword of great|
antiquity.")
    (LDESC "There is an elvish sword here.")
    (SIZE 30)
    (VALUE 0)
>

<OBJECT NEWSPAPER(LOC LIVING-ROOM)(DESC "newspaper")
    (FLAGS READBIT TAKEBIT BURNBIT)
    (LDESC "There is an issue of US NEWS & DUNGEON REPORT dated 7/22/81 here.")
    (TEXT
"        US NEWS & DUNGEON REPORT|
7/22/81                         Last G.U.E. Edition|
|
This version of ZORK is no longer being supported on this or any other|
machine.  In particular, bugs and feature requests will, most likely, be|
read and ignored.  There are updated versions of ZORK, including some|
altogether new problems, available for PDP-11s and various|
microcomputers (TRS-80, APPLE, maybe more later).  For information, send|
a SASE to:|
|
                Infocom, Inc.|
                P.O. Box 120, Kendall Station|
                Cambridge, Ma. 02142")
    (SYNONYM PAPER NEWSPAPER ISSUE REPORT MAGAZINE NEWS)
    (SIZE 2)
>

<OBJECT LAMP(LOC LIVING-ROOM)(DESC "lamp")
    (FLAGS TAKEBIT LIGHTBIT)
    (FDESC "A battery-powered brass lantern is on the trophy case.")
    (LDESC "There is a brass lantern (battery-powered) here.")
    (SYNONYM LAMP LANTERN LIGHT)(ADJECTIVE BRASS)
    (SIZE 15)
>

<OBJECT TROPHY-CASE(LOC LIVING-ROOM)(DESC "trophy case")
    (FLAGS CONTBIT OPENABLEBIT TRANSBIT)
    (LDESC "There is a trophy case here.")
    (SYNONYM CASE)(ADJECTIVE TROPHY)
>


Coding Issues


  • The definition of the object NEWSPAPER contains six synonyms. Since the ZIP (z3) format only allows a maximum of four synonyms per object, the game VERSION has been changed to XZIP (z5).
  • The library routine V-VERSION can't highlight the title of the (now XZIP) game since it can't know that the first line of the constant GAME-BANNER is the title. The definition of V-VERSION has been changed to use GAME-TITLE and GAME-DESCRIPTION instead of GAME-BANNER. GAME-TITLE is highlighted if the game version is not ZIP.

Walkthrough


Now, lets try exploring the connectivity between the rooms.

ZORK
The MIT original by Tim Anderson, Marc Blank, Bruce Daniels, and Dave Lebling.
This version written in ZIL by Shin for the ZILF compiler by Jesse McGrew.
Baseline 0 / Iteration 1 (House and Vicinity) / ZILF 0.8 lib J4

Kitchen
You are in the kitchen of the white house. A table seems to have
been used recently for the preparation of food. A passage leads to
the west and a dark staircase can be seen leading upward. To the
east is a small window which is slightly ajar.
On the table is an elongated brown sack, smelling of hot peppers.
A bottle is sitting on the table.
In the glass bottle is a quantity of water.

> u
It is pitch black. You can't see a thing.

> d
Kitchen
On the table is an elongated brown sack, smelling of hot peppers.
A bottle is sitting on the table.
In the glass bottle is a quantity of water.

> w
Living Room
You are in the living room. There is a door to the east, a wooden
door with strange gothic lettering to the west, which appears to be
nailed shut, and a large oriental rug in the center of the room.
There is a trophy case here.
A battery-powered brass lantern is on the trophy case.
There is an issue of US NEWS & DUNGEON REPORT dated 7/22/81 here.
On hooks above the mantelpiece hangs an elvish sword of great
antiquity.

> get lamp
You pick up the lamp.

> e
Kitchen
On the table is an elongated brown sack, smelling of hot peppers.
A bottle is sitting on the table.
In the glass bottle is a quantity of water.

> u
Attic
This is the attic. The only exit is stairs that lead down.
There is a square brick here which feels like clay.
A large coil of rope is lying in the corner.
On a table is a nasty-looking knife.



Comparison with Original


Repeating the walkthrough using the original only reveals that the behaviour of the lamp is not yet implemented.

Kitchen
You are in the kitchen of the white house.  A table seems to have
been used recently for the preparation of food.  A passage leads to
the west and a dark staircase can be seen leading upward.  To the
east is a small window which is open.
On the table is an elongated brown sack, smelling of hot peppers.
A bottle is sitting on the table.
The glass bottle contains:
 A quantity of water
> u
It is pitch black.  You are likely to be eaten by a grue.
> d
Kitchen
On the table is an elongated brown sack, smelling of hot peppers.
A bottle is sitting on the table.
The glass bottle contains:
 A quantity of water
> w
Living Room
You are in the living room.  There is a door to the east, a wooden
door with strange gothic lettering to the west, which appears to be
nailed shut, and a large oriental rug in the center of the room.
There is a trophy case here.
A battery-powered brass lantern is on the trophy case.
There is an issue of US NEWS & DUNGEON REPORT dated 7/22/81 here.
On hooks above the mantelpiece hangs an elvish sword of great
antiquity.
> get lamp
Taken.
> e
Kitchen
You are in the kitchen of the white house.  A table seems to have
been used recently for the preparation of food.  A passage leads to
the west and a dark staircase can be seen leading upward.  To the
east is a small window which is open.
On the table is an elongated brown sack, smelling of hot peppers.
A bottle is sitting on the table.
The glass bottle contains:
 A quantity of water
> u
It is pitch black.  You are likely to be eaten by a grue.
> turn on lamp
The lamp is now on.
Attic
This is the attic.  The only exit is stairs that lead down.
There is a square brick here which feels like clay.
A large coil of rope is lying in the corner.
On a table is a nasty-looking knife.
>


Testing the object descriptions reveals nothing new.

Saturday, 6 January 2018

House and Vicinity: The Vicinity (Explorable Map)

Zork starts in front of a white house in a forest. The vicinity of the house consists of four rooms, organised, according to the original MDL code, like this.



Now, let's try coding the details of this map in ZIL using the original MDL code to provide the text descriptions and responses.

West of House


<ROOM WEST-OF-HOUSE(IN ROOMS)(DESC "West of House")
    (FLAGS LIGHTBIT)
    (LDESC "This is an open field west of a white house, with a boarded front door.")
    (NORTH TO NORTH-OF-HOUSE)(SOUTH TO SOUTH-OF-HOUSE) ;"(WEST TO FOREST-1)"
    (EAST SORRY "The door is locked, and there is evidently no key.")
    (GLOBAL HOUSE)
>


<OBJECT HOUSE(LOC LOCAL-GLOBALS)(DESC "white house")
    (FLAGS NDESCBIT)
    (SYNONYM HOUSE)(ADJECTIVE WHITE)
    (ACTION HOUSE-F)
>


<ROUTINE HOUSE-F ()
    <COND (<VERB? LOOK-AT>
           <TELL "The house is a beautiful colonial house which is painted white.|
It is clear that the owners must have been extremely wealthy." CR>)>
>


<OBJECT FRONT-DOOR(LOC WEST-OF-HOUSE)(DESC "door")
    (FLAGS DOORBIT NDESCBIT)
    (SYNONYM DOOR)(ADJECTIVE FRONT)
>


<OBJECT MAT(LOC WEST-OF-HOUSE)(DESC "welcome mat")
    (FLAGS TAKEBIT READBIT)
    (FDESC "A rubber mat saying 'Welcome to Zork!' lies by the door.")
    (LDESC "There is a welcome mat here.")
    (TEXT "Welcome to Zork!")
    (SYNONYM MAT)(ADJECTIVE WELCOME RUBBER)
    (SIZE 12)
>

<OBJECT MAILBOX(LOC WEST-OF-HOUSE)(DESC "mailbox")
    (FLAGS CONTBIT OPENABLEBIT)
    (LDESC "There is a small mailbox here.")
    (SYNONYM MAILBOX BOX)(ADJECTIVE SMALL)
    (CAPACITY 10)
>


<OBJECT LEAFLET(LOC MAILBOX)(DESC "leaflet")
    (FLAGS READBIT TAKEBIT BURNBIT)
    (LDESC "There is a small leaflet here.")
    (TEXT "                        WELCOME TO ZORK|
|
    ZORK is a game of adventure, danger, and low cunning.  In it you|
will explore some of the most amazing territory ever seen by mortal|
man.  Hardened adventurers have run screaming from the terrors|
contained within!|
|
    In ZORK the intrepid explorer delves into the forgotten secrets|
of a lost labyrinth deep in the bowels of the earth, searching for|
vast treasures long hidden from prying eyes, treasures guarded by|
fearsome monsters and diabolical traps!|
|
    No PDP-10 should be without one!|
|
    ZORK was created at the MIT Laboratory for Computer Science, by|
Tim Anderson, Marc Blank, Bruce Daniels, and Dave Lebling.  It was|
inspired by the ADVENTURE game of Crowther and Woods, and the long|
tradition of fantasy and science fiction adventure.  ZORK is written|
in MDL (alias MUDDLE).|
|
    On-line information may be available using the HELP and INFO|
commands (most systems).|
|
    Direct inquiries, comments, etc. by Net mail to ZORK@MIT-DMS.|
|
    (c) Copyright 1978,1979 Massachusetts Institute of Technology. |
               All rights reserved.")
    (SYNONYM ADVERT PAMPHLET LEAFLET BOOKLET)(ADJECTIVE SMALL MAIL)
>


North of House


<ROOM NORTH-OF-HOUSE(IN ROOMS)(DESC "North of House")
    (FLAGS LIGHTBIT)
    (LDESC "You are facing the north side of a white house.  There is no door here,|
and all the windows are barred.")
    (WEST TO WEST-OF-HOUSE)(EAST TO BEHIND-HOUSE) ;"(NORTH TO FOREST-3)"
    (SOUTH SORRY "The windows are all barred.")
    (GLOBAL DUMMY-WINDOW HOUSE)
>


<OBJECT DUMMY-WINDOW(LOC LOCAL-GLOBALS)(DESC "window")
    (FLAGS NDESCBIT)
    (SYNONYM WINDOW)
>


South of House


<ROOM SOUTH-OF-HOUSE(IN ROOMS)(DESC "South of House")
    (FLAGS LIGHTBIT)
    (LDESC "You are facing the south side of a white house. There is no door here,|
and all the windows are barred.")
    (WEST TO WEST-OF-HOUSE)(EAST TO BEHIND-HOUSE) ;"(SOUTH TO FOREST-2)"
    (NORTH SORRY "The windows are all barred.")
    (GLOBAL DUMMY-WINDOW HOUSE)
>


Behind House


<ROOM BEHIND-HOUSE(IN ROOMS)(DESC "Behind House")
    (FLAGS LIGHTBIT)
    (NORTH TO NORTH-OF-HOUSE)(SOUTH TO SOUTH-OF-HOUSE) ;"(EAST TO CLEARING)"
    ;"(WEST TO KITCHEN IF WINDOW IS OPEN)"
    ;"(IN TO KITCHEN IF WINDOW IS OPEN)"
    (ACTION BEHIND-HOUSE-F)
    (GLOBAL HOUSE WINDOW)
>


<ROUTINE BEHIND-HOUSE-F (RARG)
    <COND (<=? .RARG ,M-LOOK>
           <TELL "You are behind the white house.  In one corner of the house there|
is a small window which is ">
           <COND (<FSET? ,WINDOW OPENBIT>
                  <TELL "open." CR>)
                 ( ELSE <TELL "slightly ajar." CR>)>)>
>


<OBJECT WINDOW(LOC LOCAL-GLOBALS)(DESC "window")
    (FLAGS DOORBIT OPENABLEBIT NDESCBIT)
    (SYNONYM WINDOW)
>


Walkthrough


Now, let's try exploring the connectivity between the rooms.

ZORK
The MIT original by Tim Anderson, Marc Blank, Bruce Daniels, and Dave Lebling.
This version written in ZIL by Shin for the ZILF compiler by Jesse McGrew.
Baseline 0 / Iteration 1 (House and Vicinity) / Status = Coding

West of House
This is an open field west of a white house, with a boarded front door.
There is a small mailbox here.
A rubber mat saying 'Welcome to Zork!' lies by the door.

> n
North of House
You are facing the north side of a white house. There is no door here,
and all the windows are barred.

> e
Behind House
You are behind the white house. In one corner of the house there
is a small window which is slightly ajar.

> s
South of House
You are facing the south side of a white house. There is no door here,
and all the windows are barred.

> w
West of House
There is a small mailbox here.
A rubber mat saying 'Welcome to Zork!' lies by the door.

> s
South of House

> e
Behind House

> n
North of House

> w
West of House
There is a small mailbox here.
A rubber mat saying 'Welcome to Zork!' lies by the door.



Comparison with Original


If we repeat the walkthrough using the original, the only apparent difference is the extra blank line between turns in the ZIL version. I think this is an improvement so I'll not attempt to fix it.

This Zork created February 23, 2017.
West of House
This is an open field west of a white house, with a boarded front door.
There is a small mailbox here.
A rubber mat saying 'Welcome to Zork!' lies by the door.
> n
North of House
You are facing the north side of a white house.  There is no door here,
and all the windows are barred.
> e
Behind House
You are behind the white house.  In one corner of the house there
is a small window which is slightly ajar.
> s
South of House
You are facing the south side of a white house. There is no door here,
and all the windows are barred.
> w
West of House
There is a small mailbox here.
A rubber mat saying 'Welcome to Zork!' lies by the door.
> s
South of House
> e
Behind House
> n
North of House
> w
West of House
There is a small mailbox here.
A rubber mat saying 'Welcome to Zork!' lies by the door.
>


Object Description Test


West of House
This is an open field west of a white house, with a boarded front door.
There is a small mailbox here.
A rubber mat saying 'Welcome to Zork!' lies by the door.

> x house
You see nothing special about the white house.

> look at house
The house is a beautiful colonial house which is painted white.
It is clear that the owners must have been extremely wealthy.

> x door
You see nothing special about the door.

> x mailbox
There is a small mailbox here.
The mailbox is closed.

> open mailbox
You open the mailbox.
In the mailbox is a leaflet.

> x leaflet
                        WELCOME TO ZORK

    ZORK is a game of adventure, danger, and low cunning. In it you
will explore some of the most amazing territory ever seen by mortal
man. Hardened adventurers have run screaming from the terrors
contained within!

    In ZORK the intrepid explorer delves into the forgotten secrets
of a lost labyrinth deep in the bowels of the earth, searching for
vast treasures long hidden from prying eyes, treasures guarded by
fearsome monsters and diabolical traps!

    No PDP-10 should be without one!

    ZORK was created at the MIT Laboratory for Computer Science, by
Tim Anderson, Marc Blank, Bruce Daniels, and Dave Lebling. It was
inspired by the ADVENTURE game of Crowther and Woods, and the long
tradition of fantasy and science fiction adventure. ZORK is written
in MDL (alias MUDDLE).

    On-line information may be available using the HELP and INFO
commands (most systems).

    Direct inquiries, comments, etc. by Net mail to ZORK@MIT-DMS.

    (c) Copyright 1978,1979 Massachusetts Institute of Technology.
               All rights reserved.

> x mat
Welcome to Zork!



Comparing with the original reveals the following differences.
  • "x" not recognised as a synonym of "examine"
  • "I" instead of "you" (I see nothing special about the white house)
  • no description of the mailbox (I see nothing special about the mailbox.)
  • single line description of opening the mailbox (Opening the mailbox reveals a leaflet.)

I don't intend to do anything about these presentational differences.