| Chapter 6: Descriptions |

| 6.7. 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."

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.

62
| Example Mistress of Animals A person who moves randomly between rooms of the map.

Suppose we want a restless sort of character always pacing from room to room. It is quite easy to use adjacency to achieve this effect: "Mistress of Animals" Corinth is a room. Athens is east of Corinth. Epidaurus is southeast of Corinth and east of Mycenae. Mycenae is south of Corinth. Olympia is west of Mycenae. Argos is south of Mycenae. Thebes is northwest of Athens. Pylos is south of Olympia. Sparta is east of Pylos and south of Argos. Delphi is northwest of Thebes. Artemis is a woman in Thebes. Every turn: if Artemis is in a room (called the current space) begin; let next space be a random room which is adjacent to the current space; if Artemis is visible, say "Artemis heads to [the next space]."; move Artemis to next space; if Artemis is visible, say "Artemis arrives from [the current space]."; end if. Test me with "z / z / z / z / z / z". Of course, it helps that Artemis is the sort to like open spaces. The implementation would become more complicated if there were doors which might block transit between these locations.

63
| 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.

64
| 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.

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

Previous | Contents | Next