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