Chapter 6: Descriptions
6.14. Adjacent rooms and routes through the map

Another useful adjective built into Inform is "adjacent". Two rooms are said to be adjacent if there is a map connection between them which does not pass through some barrier such as a door. This is easily tested:

if the Hallway is adjacent to the Study ...

We usually want to know about the places adjacent to the current scene of the action, so that is what the adjective "adjacent" means when applied to rooms. For instance:

if somebody is in an adjacent room, ...

As with the case of "visible", the adjective is a cut-down version of the more general relationship. This often happens: "worn" and "carried", for instance, imply "by the player" unless something else is specified.

If we want to ask a more direct question, we can obtain specific map connections like so:

say "You look north into [the room north from the Garden]."

since "the room D from A" produces the room which lies in direction D from room A. We need to be a little careful here. What if there is no map connection this way? In that case, "the room ... from ..." produces the special value "nothing". Thus:

if the room north from the Garden is nothing, say "The grass leads nowhere."

Of course, the way north might pass through a door, which might be an obstacle. We could check this by looking at:

let the barrier be the door north from the Garden;
if the barrier is a door, say "Well, [the barrier] is in the way.";

(Again, this produces either a door or else the special value "nothing".)

While on the subject of navigating the map, the phrase "the best route from A to B" gives a direction to take in order to get from A to B by the shortest number of movements between rooms - if there is any way through at all. For example, here is a lure:

The description of the brass compass is "The dial points quiveringly to [best route from the location to the Lodestone Room]."

Best routes are ordinarily forbidden to go through doors, but if the suffix "using doors" is added as an option then any open or openable and unlocked door may be used on the way; and if "using even locked doors" is given, then any door at all will do. Since magnetism is no respecter of property, that seems right here:

The description of the brass compass is "The dial points quiveringly to [best route from the location to the Lodestone Room, using even locked doors]."

The phrase "the best route from A to B" gives the direction to take next, if we are at A and want to end up at B. Suppose this is east. We can find out where we go next by looking up "the room east from A": similarly for any other direction, of course. (This can see through any doors, locked or not.)

We can also stipulate that only certain rooms may be used for the journey, as in the following example:

best route from the Drawbridge to the Keep through visited rooms

The condition - in this case, that "visited rooms" must be used - also applies to both ends of the journey. (Also, saying something like "...through containers" would mean there is never a route, since it is only rooms which appear on the map.)

Lastly, we can find out how long the journey would be:

The description of the proximity gadget is "You are now [number of moves from the location to the Sundial] moves from the Sundial.";

This number is, of course, 0 if the location is already the Sundial. If there is no way at all to get to the Sundial, the number is -1.

Route-finding makes it possible to write quite sophisticated conditions concisely. But these sometimes run slowly, because they call for large amounts of computation. How rapidly Inform can find routes depends on which of two methods it uses. Both have advantages - one is fast but needs large amounts of memory, the other is slow but economical. We can choose between them with one of these two use options:

Use fast route-finding.
Use slow route-finding.

If neither is specified, "fast" is used where the project uses the Glulx virtual machine (see the Settings panel), and "slow" on the Z-machine, where memory is tighter. Fast route-finding is ideally suited to situations where dozens of characters are constantly route-finding through the map as they meander around in a landscape.

(- See Indirect relations for route-finding through a relation rather than the map.)


75
* Example  Mistress of Animals
A person who moves randomly between rooms of the map.

RB
76
* Example  All Roads Lead to Mars
Layout where the player is allowed to wander any direction he likes, and the map will arrange itself in order so that he finds the correct "next" location.

RB

Suppose we want to allow the player to wander freely in any direction, but ourselves maintain control over the order in which he encounters the rooms. This sort of effect emphasizes the order of the story-telling over any kind of rigorous simulation of space; on multiple play-throughs, the player might not find all the same rooms in the same locations.

"All Roads Lead to Mars"

Before going a direction (called way) when a room (called next location) is not visited:
    let further place be the room the way from the location;
    if further place is a room, continue the action;
    change the way exit of the location to the next location;
    let reverse be the opposite of the way;
    change the reverse exit of the next location to the location.

The Open Plain is a room. "A wide-open grassy expanse, from which you could really go any way at all."

The Hilly Place is a room. "The grassland gives way to a somewhat more hilly area, though there is still very little to guide you any particular way."

The Stream is a room. "This is the third place you've been today, and so the stream is welcome. How refreshing!"

Test me with "n / s / e / e".

If we wanted still to be able to find routes between places, we could define a relationship of connection between rooms, which we would add to as we went along.

77
** Example  Hotel Stechelberg
Signposts such as those provided on hiking paths in the Swiss Alps, which show the correct direction and hiking time to all other locations.

RB
78
*** Example  A View of Green Hills
A LOOK [direction] command which allows the player to see descriptions of the nearby landscape.

RB


PreviousContentsNext