Inform 7 Home Page / Documentation
§6.9. Going, Pushing Things in Directions
Going is the most complex of actions after looking (or perhaps including looking): the success of every movement depends on the direction the player goes; the room he starts from; the room he intends to reach; whether there are any doors intervening (and, if so, whether these are closed or locked); whether he is traveling by vehicle; and whether he is pushing anything in front of him. When he gets there, the description he sees is itself generated by a looking command.
Pushing something in a direction is really a sort of going. The command >PUSH WHEELBARROW WEST first checks certain qualifying rules: by default, only things defined as pushable between rooms may be pushed, and they may be pushed only in horizontal directions (not UP or DOWN) -- though these rules can be overridden, as we see in Zorb. If the player's pushing attempt passes these criteria, the action is translated automatically into a going action, with all the usual checks about whether that direction leads anywhere, whether a door is in the way, and so on. The converted action afterward can be caught with such rules as
Instead of going to the Alpine Meadow with the wheelbarrow:
say "You don't want to crush the delicate blooms."
Instead of going north with the handcart:
say "The headwind is so stiff that you are unable to make much northerly progress at all while encumbered by the handcart."
Since the two actions are internally being handled as one, both are discussed here.
It is very common for players to make a mistake and type the wrong direction command, or even to misunderstand the room description and not recognize all the possible exits. Bumping into Walls helpfully adds a facility so that when the player tries to go in the wrong direction, the story lists the correct possibilities, as in
From here, the viable exits are to the south, the east and the west.
Assuming that travel succeeds, another useful technique is to provide some sense of the journey between locations, especially if they are remote from one another or the player has to do something unusual to get from one to the other. Up and Up adds a short description of travel when we approach a new room, before the room description is printed; Veronica, conversely, adds a comment when the player leaves a region of the map. The Second Oldest Problem intervenes and kills a player who tries to travel from one dark room to another. Mattress King embellishes the description that automatically results from PUSH MATTRESS WEST, adding a line that describes the player pushing the object before describing the new room approached.
We may also want to add a brief comment when we arrive in a new room, after the room description is printed. One trivial way to do this is to append the line to the room's main description, conditionally, like this:
The Hammock Emporium is a room. "This is Cousin Ed's shop, the big dream he left accounting to pursue. You can't help gawking at the Luxury Leather Space Hammock, made of genuine red buffalo skins[if unvisited]. [paragraph break]So this is why Grampa makes all those 'lying down on the job' jokes every Thanksgiving[end if].".
But often we want our first-glance comment to come after some items in the room are described; and for this effect, we would use the "first look rule" defined in Saint Eligius.
If these methods are not enough, the looking action has an action-specific variable called "the room-describing action", which records whether this particular instance of looking comes about because the player typed LOOK or because the player traveled to a new location. We can consult this variable if we want to make looking work differently after going, as for instance here:
Check looking when the room-describing action is the going action:
say "You are temporarily too blinded to see." instead.
Another category of examples treat how we handle the movement commands themselves. The eight compass directions, with UP and DOWN, IN and OUT, are used as standard in most interactive fiction, but they are not the only possible way of navigating, and strike many newcomers to the genre as counter-intuitive, since when strolling around in real life most of us rarely think about our travel in terms of compass orientation. Misadventure allows the player to GO TO a named room, instead, and calculates the best route to reach the destination; Safari Guide builds on this by letting the player make the whole trip in a single move, automatically opening any doors that stand in his way en route.
In the same spirit of interpreting the player's intentions sensibly, Provenance Unknown modifies the pushing command so that if the player pushes the top object in a stack of objects towards a direction, Inform attempts to move the bottom item instead. This is convenient if, for instance, we have a heavy television on a movable cart and want PUSH TELEVISION WEST to work just as well as PUSH CART WEST.
We also sometimes want to respond sensibly to terse movement commands or ones that rely on some knowledge of where the player has already been. Polarity provides a GO BACK command, allowing the player to retreat in the direction from which he came, while Minimal Movement understands LEAVE, GO, and so on as OUT, in the absence of other information. Owen's Law takes this further, calculating from the best routes on a map how to make OUT mean "move towards the exit of this indoor room", and IN mean "proceed further into the interior". Wonderland assigns altitudes to all rooms and works out the local best meaning of UP and DOWN accordingly.
See Map for how to create other kinds of new direction
See Varying What Is Read for further divisions of the standard compass, such as north-northwest
See Ships, Trains and Elevators for ship-board directions
See Bicycles, Cars and Boats for common vehicles in which to travel the map
|
ExampleVeronica
An effect that occurs only when the player leaves a region entirely.
|
|
Suppose that we want to have something happen when the player leaves a region we've defined. "Instead of going from (the region)..." will not suffice for this, because this rule will be invoked every time the player successfully leaves a room within the region, whether or not he is going to a room that is also in the same region.
Instead we need a rule that is a bit more specific, like this:
"Veronica"
Neptune is a region.
Tijuana is a room.
High School is north of Tijuana. It is in Neptune.
Detective Offices is west of High School. It is in Neptune.
The player is in High School.
Instead of going from Neptune to a room which is not in Neptune:
say "It's a bad time to leave Neptune."
Test me with "s / w / e".
By default, when the player pushes something a direction, Inform checks to make sure that the object is pushable between rooms. If not, it blocks the action; if so, it carries out a normal going action with the pushed object taken along.
Also by default, this action produces only a description of the new room that we've traveled into. But suppose we would like to print a short message describing the pushing action first:
"Mattress King"
Monica's Bedroom is a room. The Living Room is south of Monica's Bedroom. Rachel's Bedroom is south of the Living Room.
After going a direction (called way-pushed) with something (called the thing-pushed):
say "You push [the thing-pushed] [way-pushed] to [the location].";
continue the action.
The race car bed is an enterable supporter in Monica's Bedroom. It is pushable between rooms.
Test me with "push bed south".
Text in this example is drawn from Will Crowther's original 1976 FORTRAN implementation of ADVENTURE, the founding work of the genre, whose source code was rediscovered by Dennis G. Jerz in 2007. Note the capitals: the program ran on an early computer without lower case lettering. They look a little mimsy now, but picture them glowing green on an old-style cathode ray tube monitor in a darkened room late at night.
The problem alluded to is that the player is forbidden to walk between two dark rooms, so that he must always have light to see by from at least one end of any movement. Writing source text to achieve this is tricky to get right in every case, because the determination of light is hard to do. Here we interleave the necessary rules into the existing "going" action, using a new action variable to record the number of ends which are dark as experienced by the player, which might be 0, 1 or 2:
"THE SECOND OLDEST PROBLEM"
The going action has a number called the dark terminus count.
Setting action variables for going:
now the dark terminus count is 0;
if in darkness, increment the dark terminus count.
The last carry out going rule:
if in darkness, increment the dark terminus count;
if the dark terminus count is 2, end the story saying "YOU FELL INTO A PIT AND BROKE EVERY BONE IN YOUR BODY!" instead.
And now three early rooms to try this out.
COBBLE CRAWL is a room. "YOU ARE CRAWLING OVER COBBLES IN A LOW PASSAGE. THERE IS A DIM LIGHT AT THE EAST END OF THE PASSAGE."
DEBRIS ROOM is west of COBBLE CRAWL. "YOU ARE IN A DEBRIS ROOM, FILLED WITH STUFF WASHED IN FROM THE SURFACE. A LOW WIDE PASSAGE WITH COBBLES BECOMES PLUGGED WITH MUD AND DEBRIS HERE,BUT AN AWKWARD CANYON LEADS UPWARD AND WEST."
AWKWARD CANYON is west of DEBRIS ROOM. "YOU ARE IN AN AWKWARD SLOPING EAST/WEST CANYON."
DEBRIS ROOM and AWKWARD CANYON are dark.
Rule for printing the name of a dark room: say "DARKNESS" instead.
Rule for printing the description of a dark room: say "IT IS NOW PITCH BLACK. IF YOU PROCEED YOU WILL LIKELY FALL INTO A PIT." instead.
Test me with "w / e / w / w".
This is only the second oldest problem in the IF literature: the earliest puzzle is unlocking the steel grate which bars entrance to the cave.
|
ExampleMisadventure
A going by name command which does respect movement rules, and accepts names of rooms as commands.
|
|
The original Adventure allowed the player to type the names of rooms in order to move to them, and it is now not too difficult for us to do the same. Adventure restricted this option to adjacent rooms, but we might want to be a bit more flexible, so we will accept any room:
"Misadventure"
Plover Room is a room. "You're in a small chamber lit by an eerie green light. An extremely narrow tunnel exits to the west. A dark corridor leads northeast."
The Dark Corridor is northeast of Plover Room. Plover Room is south of the Dark Corridor. The printed name of the Dark Corridor is "Dark Room". The description of the Dark Corridor is "You're in the dark-room. A corridor leading south is the only exit."
The Alcove is west of Plover Room. "You are in an alcove. A small northwest path seems to widen after a short distance. An extremely tight tunnel leads east. It looks like a very tight squeeze. An eerie light can be seen at the other end."
Northwest of the Alcove is the Misty Cavern. The description of Misty Cavern is "You are following a wide path around the outer edge of a large cavern. Far below, through a heavy white mist, strange splashing noises can be heard. The mist rises up through a fissure in the ceiling. The path exits to the south and west." West of Misty Cavern is the Alcove.
Understand "[any room]" as going by name. Understand "go to [any room]" as going by name.
Going by name is an action applying to one thing.
We should reject movement to the player's current location, or to anywhere he hasn't been and can't see:
Check going by name:
if the noun is the location, say "You're already in [the location]." instead;
if the noun is not adjacent and the noun is unvisited, say "That noun did not make sense in this context." instead.
The assumption here is that the player does know the names of the rooms adjacent to his current location, even if he hasn't been there yet.
Now for the travel itself. The simplest way to ensure that the usual movement rules will still apply is to convert GO BY NAME into a GO action, and here the best route comes to our aid:
Carry out going by name:
let aim be the best route from the location to the noun, using doors;
if aim is not a direction, say "You can't think how to get there from here." instead;
say "(heading [aim])[command clarification break]";
try going aim;
if the location is not the noun, say "You'll have to stop here."
This will allow the player to travel toward rooms he has already visited even if they are several moves away.
Finally, so that the player can also use the names of doors as commands:
Understand "[door]" as entering.
And in keeping with the original, we might add to our scenario a rule or two about restrictions on movement, just to test that it's all working right:
The player carries a plover egg and a platinum pyramid. The description of the egg is "Plover's eggs, by the way, are quite large." The printed name of the egg is "emerald the size of a plover's egg". Understand "emerald" as the egg. The description of the pyramid is "The platinum pyramid is 8 inches on a side!"
Instead of going to the Plover Room from the Alcove when the player carries something which is not the plover egg:
say "Something you're carrying won't fit through the tunnel with you. You'd best take inventory and drop something."
Test me with "go to misty cavern / go to dark corridor / go to plover room / go to alcove / go to dark corridor / drop pyramid / go to dark corridor / g / go to alcove / g / go to misty cavern".
|
ExampleMinimal Movement
Supplying a default direction for "go", so that "leave", "go", etc., are always interpreted as "out".
|
|
Sometimes it would be nice to respond a little more sensitively to a vague command such as "leave" -- converting it, perhaps, to a "go out" command.
"Minimal Movement"
The Doll-like House is a room. The Postage-Stamp-Sized Garden is outside from the House.
Rule for supplying a missing noun while going:
now noun is outside.
This particular situation is very slightly complicated by the existing rules about vague movement, but fortunately we can easily turn those off.
The block vaguely going rule is not listed in the for supplying a missing noun rules.
Test me with "go".
|
ExampleSaint Eligius
Adding a first look rule that comments on locations when we visit them for the first time, inserting text after objects are listed but before any "every turn" rules might occur.
|
|
A not-infrequent desire in IF is to provide a few lines of comment when the player first enters a new room, after the objects are described but before anything else (such as an every turn rule) can fire. The cleanest, most systematic solution is to add a rule to the carry out looking rulebook, so:
"Saint Eligius"
The first look rule is listed after the room description paragraphs about objects rule in the carry out looking rules. A room can be commented or uncommented. A room is usually uncommented.
This is the first look rule:
if the location is uncommented, carry out the gawking at activity with the location.
Gawking at something is an activity.
Rule for gawking at the Diamond Market:
say "Your throat closes and your eyes begin to sting. You have long disdained pomp and luxury, and railed against the oppression that brings such wealth to some men at the cost of the lives of others; you were not prepared for the magnificence."
After gawking at a room (called the target): now the target is commented.
And now the scene itself:
The Cobbled Alley is a room. "The Alley has never been made into a proper street: the buildings on either side are simply too important to tear down. For all that, there isn't much sign of the magnificence nearby. The entrance you seek is set below street level, four grimy steps down to a half-basement."
After going to Diamond Market:
say "You descend the steps quickly and step into the small foyer, allowing yourself to be searched for weapons, before going on to...";
continue the action.
Diamond Market is down from Cobbled Alley. "The roof is vaulted and painted in allegorical images representing Plenty, the Riches of the Earth, and Saint Eligius, patron of goldsmiths and jewelers.
Under their watchful eye, dozens of men in sober black robes sit; and on the tables before them are rubies, emeralds, sapphires from oversea, but most of all diamonds, both raw and cut."
The burly guard is a man in Diamond Market. "A burly guard patrols quite close to you, but even he is more sumptuously dressed than the average burly guard, and his buttons shine."
Test me with "d / look".
|
ExampleUp and Up
Adding a short message as the player approaches a room, before the room description itself appears.
|
|
Sometimes when a player moves from one room to another, we want to imply that a considerable amount of time elapses, or that something interesting occurs on the way. In that case, we might want to print more than just the room description itself. Here is how we might define a couple of rooms that are far apart:
"Up and Up"
The Plain of the Skull is below the Endless Tower. The description of the Plain of the Skull is "A vast and trackless plain, enlivened only by the bones of those who have previously tried and failed to cross. Above you is the Endless Tower, which rises half-way to the moon."
The description of the Endless Tower is "From up here the Plain of the Skull seems only a small bald patch: the world is round and most of it is covered with trees. Far off to the southwest is a shimmering surface that might be water; but there are no signs of cities or civilizations, only the lizard-skeletons."
And now we borrow from the instructions on Actions to create our actual message. "Before..." introduces a rule that occurs when the player tries to do something; in this case, we will make a Before rule for going to the tower.
Before going to the Endless Tower:
say "You climb... and climb... and climb... The sun sets. The moon rises. The wind begins to blow. You continue to climb..."
The player carries a bit of harness. The description of the harness is "A strip of worked leather and a loop of metal, scavenged from one of the skeletons on the plain. Without it, you might think your entire quest was in vain."
Test me with "look / up".
|
ExampleWonderland
Hiking Mount Rainier, with attention to which locations are higher and which lower than the present location.
|
|
Suppose we have a landscape with a great deal of up and down variation, where GO UP and GO DOWN will be significant almost everywhere, and specifying them all individually a tremendous pain:
"Wonderland"
An altitude is a kind of value. 1000 feet specifies an altitude. A room has an altitude.
Definition: a room is low if its altitude is 3000 feet or less. Definition: a room is high if its altitude is 5000 feet or more.
Instead of going down:
if an adjacent room is lower than the location:
let the valley be the lowest adjacent room;
let the way be the best route from the location to the valley;
say "(that is, [way])[paragraph break]";
try going the way;
otherwise:
say "You're in a local valley: there's no down from here."
Instead of going up:
if an adjacent room is higher than the location:
let the peak be the highest adjacent room;
let the way be the best route from the location to the peak;
say "(that is, [way])[paragraph break]";
try going the way;
otherwise:
say "You're on a local peak."
Paradise is a room. Paradise has altitude 5400 feet. "A handsome parking lot, a picnic ground, and the Henry M. Jackson Memorial Visitor Center. The latter offers, for serious climbers, a hot shower; for nature enthusiasts, an interpretive museum; and for car-trippers, a gift shop selling canned slugs. All of which is a largely unsuccessful distraction from the peak of Mt. Rainier beyond."
Cougar Rock is southwest of Paradise. The altitude of Cougar Rock is 3180 feet. "Numerous individual campsites and (on the road inventively labeled 'F') a handful of larger campgrounds suitable for church groups and family reunions."
Longmire is southwest of Cougar Rock. It has altitude 2760 feet. "A tiny town: it has to offer a few groceries, a post office, and a lodge for people who do not care to camp, all built in a rustic Park Service way."
Panorama Point is north of Paradise. It has altitude 6800 feet. Camp Muir is north of Panorama Point. It has altitude 10188 feet. Columbia Crest is northwest of Camp Muir. It has altitude 14410 feet. St Andrews Rock is west of Columbia Crest. It has altitude 10992 feet. Camp Schuman is northeast of Columbia Crest. It has altitude 9510 feet.
Since Mount Rainier National Park runs to over 235,000 acres, we will omit the rest of the locations, but it does seem fair to give a little more credit to anyone who makes the summit:
Instead of going up in the highest room:
say "You're standing at the summit of Mt. Rainier, the highest point in the state of Washington. There is no up."
Test me with "up / up / up / down / down / up / up".
|
ExampleSafari Guide
The same functionality, but making the player continue to move until he reaches his destination or a barrier, handling all openable doors on the way.
|
|
The foregoing example moves the player one location towards his destination, and requires that rooms have been visited before. But suppose we wanted to be a bit more lenient about movement, and let the player make as many steps as necessary per turn. We will also show consideration about doors, using the "Locksmith" extension supplied with Inform. (Now every time the code attempts opening a door, unlocking rules will also be invoked.)
"Safari Guide"
Include Locksmith by Emily Short.
The Monkey House is a room. The African Grasslands Exhibit is north of the Monkey House. The bird door is north of the African Grasslands Exhibit and south of the Aviary. The Ostrich Enclosure is west of the Aviary. The bird door is a door. It is closed, lockable, and locked. The silver key is a passkey. It unlocks the bird door. The player carries the silver key.
Understand "go to [any room]" as going by name. Understand "[any room]" as going by name. Understand "[door]" as entering.
Going by name is an action applying to one thing.
Check going by name:
if the noun is the location, say "You're already in [the location]." instead.
Carry out going by name:
while the player is not in the noun:
let heading be the best route from the location to the noun, using even locked doors;
if heading is not a direction, say "You can't think how to get there from here." instead;
let destination be the room heading from the location;
say "(heading [heading])[command clarification break]";
try going heading;
if the player is not in the destination, rule fails.
Test me with "go to aviary / go to ostrich enclosure / african grasslands".
Notice that we continue the movement until one of two things happens: either the player reaches the room that is his destination, or the going attempt doesn't work. In the latter case we stop the action in order to avoid hanging the game up in a loop. This event might occur when the player runs into a locked door, for instance.
"Bumping into Walls"
First we add an instruction to determine which ways lead to other rooms.
Definition: a direction (called thataway) is viable if the room thataway from the location is a room.
Now we build in the instruction for what Inform should say if the player tries to head in a direction that leads nowhere:
Instead of going nowhere:
let count of exits be the number of viable directions;
if the count of exits is 0, say "You appear to be trapped in here." instead;
if the count of exits is 1, say "From here, the only way out is [list of viable directions].";
otherwise say "From here, the viable exits are [list of viable directions]."
There is no theoretical reason why we have to define "count of exits" here: we could, if we wanted, just say "if the number of viable directions is 0", "if the number of viable directions is 1", and so on. However, each calculation of a "viable direction" takes a bit of computing power, so there is some slight savings in not requiring the game to count viable directions more than once in this routine.
Dome is a room. North of Dome is North Chapel. South of the Dome is South Chapel. West of the Dome is Western End. Quiet Corner is northwest of the Dome, north of Western End, and west of North Chapel. Loud Corner is east of North Chapel, northeast of Dome, and north of Eastern End. Eastern End is north of Dim Corner and east of Dome. Dim Corner is southeast of Dome and east of South Chapel. Ruined Corner is southwest of Dome, west of South Chapel, and south of Western End.
The Crypt is below the dome.
The church door is east of Eastern End and west of the Courtyard. The church door is a door.
Test me with "u / n / n / e / n / s / u / open door / e / n".
The main trick of this is always to record where the player has gone when he has just moved.
"Polarity"
The former location is a room that varies.
Here we record where the player has been before moving him; by calling this the "first carry out going rule", we make sure that this rule is followed during the going action before any other pieces of the movement occur. For more detail, see the chapters on advanced actions and on rules.
First carry out going rule:
now the former location is the location.
Understand "go back" as retreating. Understand "back" or "return" or "retreat" as retreating.
Retreating is an action applying to nothing.
Carry out retreating:
let way be the best route from the location to the former location, using doors;
if way is a direction, try going way;
otherwise say "You can't see an open way back."
And to deal with the case where the player has not yet moved:
When play begins: now the former location is the Dome.
Instead of retreating when the former location is the location: say "You haven't gone anywhere yet."
Dome is a room. North of Dome is North Chapel. South of the Dome is South Chapel. West of the Dome is Western End. Quiet Corner is northwest of the Dome, north of Western End, and west of North Chapel. Loud Corner is east of North Chapel, northeast of Dome, and north of Eastern End. Eastern End is north of Dim Corner and east of Dome. Dim Corner is southeast of Dome and east of South Chapel. Ruined Corner is southwest of Dome, west of South Chapel, and south of Western End.
The church door is east of Eastern End and west of the Courtyard. The church door is a door.
Test me with "back / n / go back / e / open door / go through door / go back".
Suppose we have a series of items that might be stacked on top of one another -- say a heavy television on a rolling cart, and we want the player to be able to move the cart with PUSH TELEVISION EAST just as well as with PUSH CART EAST.
This takes a little redirection, using a setting action variables rule. This is not a kind of rule we've encountered yet, and in fact we won't meet it until the Advanced Actions chapter; it is included here for the convenience of authors who want to modify the effect of pushing without reading that far ahead:
"Provenance Unknown"
Setting action variables for pushing something to:
if the noun is enclosed by a pushable between rooms thing (called the pushed item) which is in the location:
now the noun is the pushed item instead.
This rule says that any time we push an object that is on top of a stack of pushable objects, we should transfer the action to the item at the bottom of the stack.
The rest is merely a test case.
The heavy golden idol is on a roller board. The roller board is on a hovercraft.
The hovercraft, the tea trolley, and the skateboard are pushable between rooms.
The hovercraft is in Zeta Proximan Dig Field.
Zeta Proximan Dig Field is a room. "During the day, the field is massed with sweating native workers, overseers, and officials from central command. Now the spades, trowels, brushes, metal detectors, ground probes, plumb lines, and sighting tripods have been laid aside.
All that remains are the trenches and the fine grey dust that blows slowly across them; the moonlight; and the just-emerging outlines of an ancient and alien wall."
The Hover-Road is west of the Dig Field. "A long road hastily laid down, stretching east to west, from the dig site toward the safety of the city."
When play begins:
say "You have, at last, loaded your illicit cargo without setting off any of the many and sensitive alarms set here; now it remains only to sneak out of the area, under the light of Zeta Proxima's lone green moon."
Test me with "push idol west / look / push roller board east / look".
There are two aspects of Inform's handling of pushable objects that are particularly prime for modification. One is that we may want to change the language used to refuse the pushing of unpushable objects.
Second, Inform by default assumes that it is impossible to push objects in up or down directions. This makes lots of sense if the player is trying to push a wheelbarrow up a ladder; it makes less sense if instead we're pushing a ball up a slope.
We solve both problems with some syntax borrowed from the chapter on rulebooks: in the first case, we replace the old rule with a new one with more friendly phrasing; in the second, we remove the rule entirely. More about how to do this is described in the rulebooks chapter; and in general we can find out what rules contribute to any given action by looking at the Actions index. In this case, the action is "pushing it to", which has its own set of prerequisites (called check rules) that make sure the object can safely be pushed, before turning processing over to the going action.
"Zorb"
Section 1 - Procedure
The new can't push unpushable things rule is listed instead of the can't push unpushable things rule in the check pushing it to rules.
This is the new can't push unpushable things rule:
if the noun is not pushable between rooms:
say "[The noun] [are] not amenable to being pushed from place to place." instead.
The can't push vertically rule is not listed in any rulebook.
And now to provide a scenario where the player can push something up and down a hillside. Most of the rest of the example is there for local color and to provide a way to demonstrate these rule adjustments:
Section 2 - Scenario
The Steep Hill is a room. The Crest is above Steep Hill. The Valley is below Steep Hill.
The flat rock is a fixed in place thing in the Steep Hill.
The Zorb is a transparent open enterable container in the Steep Hill. "[if the player props the Zorb]The Zorb rests here, kept from further rolling by your support[otherwise]The Zorb is here[end if].". It is pushable between rooms. The description of the Zorb is "A giant plastic inflatable ball, like a hamster ball for humans[if someone is in the Zorb]. Inside [is-are list of people in the Zorb][end if]."
Lucy is a woman in the Zorb.
Carry out going with the Zorb when the Zorb contains Lucy:
say "Lucy whoops delightedly as she rides along in the Zorb."
Every turn when the Zorb is not in the Valley and the player does not prop the Zorb:
let next room be the room down from the location of the Zorb;
if the player is not in the Zorb and the player can see the Zorb:
say "The Zorb succumbs to gravity and rolls down toward [the next room].";
move the Zorb to the next room;
if the player is in the Zorb:
say "The Zorb rolls you down the hill!";
try looking;
otherwise if the player can see the Zorb:
say "The Zorb rolls ponderously but inevitably into the vicinity.";
Propping relates one person to one thing. The verb to prop means the propping relation.
Carry out going with the Zorb:
now the player props the Zorb.
Before doing something when the action requires a touchable noun:
if the noun is not the Zorb, now the player does not prop the Zorb.
Check waving hands when the player is propping something (called casualty):
try the player releasing the casualty.
Carry out entering the Zorb:
now the player does not prop the Zorb.
Understand "let go of [something]" or "let [something] go" or "release [something]" or "free [something]" as releasing. Releasing is an action applying to one thing.
Check releasing:
if the player carries the noun:
try dropping the noun instead.
Check releasing:
if the player does not prop the noun:
say "You are not supporting [the noun]." instead.
Carry out releasing:
now the player does not prop the noun.
Report releasing:
say "You let go of [the noun]."
Test me with "d / push zorb up / look / push zorb up / wave / d / d / push zorb up / release zorb / d / push zorb up / touch rock / push the flat rock south".
Suppose we want the game to interpret "GO OUT" as "move towards an outdoors room, or towards a room with more exits than the current room", while "GO IN" means "move toward a room with fewer exits, or towards an indoors room". Thus going in repeatedly within a building would lead towards dead-ends, while going out repeatedly would lead towards the center of the building and then towards an exit to the outside world.
We start by encoding these rules as definitions:
"Owen's Law"
A room can be indoors or outdoors. A room is usually indoors.
Definition: a room is outward:
if it is not adjacent, no;
if it is indoors and the location is outdoors, no;
if it is outdoors and the location is indoors, yes;
if the number of rooms adjacent to it is greater than the number of rooms adjacent to the location, yes;
otherwise no.
Definition: a room is inward:
if it is not adjacent, no;
if it is outdoors and the location is indoors, no;
if it is indoors and the location is outdoors, yes;
if the number of rooms adjacent to it is less than the number of rooms adjacent to the location, yes;
otherwise no.
Instead of going nowhere when the noun is outside: try exiting.
Instead of exiting when the player is in a room:
if at least one room is outward:
let the destination be a random outward room;
let the way be the best route from the location to the destination;
say "(that is, [way])[command clarification break]";
try going the way instead;
otherwise:
say "It's not entirely obvious which way you mean. ";
carry out the listing available exits activity.
Instead of going inside when the room inside from the location is not a room and at least one room is inward:
if more than one room is inward:
carry out the listing available exits activity;
otherwise:
let the destination be a random inward room;
let the way be the best route from the location to the destination;
say "(that is, [way])[command clarification break]";
try going the way instead.
Instead of going nowhere:
carry out the listing available exits activity.
This "listing available exits" is a refinement borrowed from a future chapter, which allows us to specify special listing and printing rules:
Listing available exits is an activity.
Rule for listing available exits:
if going inside and an adjacent room is inward:
say "From here 'in' could reasonably mean [a list of adjacent inward rooms].";
rule succeeds;
if exiting and an adjacent room is outward:
say "From here 'out' could reasonably mean [a list of outward adjacent rooms].";
rule succeeds;
say "From here you can go [a list of adjacent rooms]."
Before printing the name of a room (called the target) while listing available exits:
let aim be the best route from the location to the target;
say "[aim] to the ".
Rule for printing the name of an unvisited room which is not the location:
say "unknown location".
Dune is an outdoors room. "Hundreds of feet of dune stretch west to the beach, crisscrossed with dune-buggy tracks and the footprints of birds. To the east is a low-lying, boxy concrete installation."
Ocean Shores Military Installation is east of the Dune. It is an outdoors room. "The World War II emplacements, built in case of Japanese invasion, have never been destroyed, though with all the weapons and furnishings gone it is difficult to make much sense of the original structure. A doorway leads west into concrete-lined darkness; a rusty but reliable ladder ascends to a walkway overlooking the sea."
Walkway is above Ocean Shores Military Installation. "From here you have a long view of the dunes and the Pacific Ocean, complete with the rotting hull of a long-stranded vessel."
Dark Echoing Room is inside from Ocean Shores Military Installation. Dank Dripping Room is east of Dark Echoing Room. Narrow Room is south of Dark Echoing Room. Small Sealed Chamber is north of Dark Echoing Room. Room Smelling of Animal Urine is north of Dank Dripping Room. The description of a room is usually "It is dark in here, and feels unsafe."
Test me with "e / u / d / in / s / out / n / out / e / in / out / out / out".