Bronze — 37 of 46

Emily Short

Release 13

Section 5 - Go To (any room)

Understand "go to/around/near/by [something]" as walking toward. Walking toward is an action applying to one visible thing. Carry out walking toward: say "It is not necessary to specify movement within the room." Understand "go on/through/across/around [a floor]" as walking toward.

Instead of walking toward the castle when the player is in the Drawbridge:

try going north.

A person can be staid or hurrying. The player is staid.

Understand "go to [any room]" or "go back to [any room]" or "return to [any room]" or "revisit [any room]" as approaching.

Approaching is an action applying to one thing.

Check approaching:

if the noun is the location, say "You're already in [the location]." instead.

Carry out approaching:

let initial location be the location;

while the player is not in the noun

begin;

let heading be nothing;

if the noun is adjacent to the location

begin;

let heading be the best route from the location to the noun, using doors;

otherwise;

if the player carries the candle, let heading be the best route from the location to the noun through visited rooms, using doors;

otherwise let heading be the best route from the location to the noun through scouted rooms, using doors;

if heading is not a direction

begin;

if the player carries the candle, let heading be the best route from the location to the noun through visited rooms, using even locked doors;

otherwise let heading be the best route from the location to the noun through scouted rooms, using even locked doors;

end if;

end if;

if heading is not a direction

begin;

say "You can't think how to get there from here." instead;

end if;

let destination be the room heading from the location;

if location is initial location, say "You head ";

if in darkness

begin;

if the location is initial location, say "uncertainly in what feels like the right direction, based on dimly apprehended light, and the movements of air[run paragraph on]";

otherwise;

if location is not the initial location

begin;

if destination is the noun, say "And [if the initial location is dark]then[otherwise]finally[end if] ";

otherwise say "Then ";

end if;

say "[heading] to [the destination in lower case]. [run paragraph on]";

end if;

if the destination is not the noun

begin;

now the player is hurrying;

silently try going heading;

otherwise;

say "[paragraph break]";

now the player is staid;

try going heading;

end if;

if the player is not in the destination

begin;

now the player is staid;

rule fails;

otherwise;

if initial location is dark and destination is not dark and destination is not the noun, say ", emerging into [the destination in lower case]. [run paragraph on]";

end if;

end while.

Before going through a closed door (called obstacle) when the player is hurrying:

silently try opening the obstacle.

Before opening a locked door when the player is hurrying and the player carries the matching key of the noun:

silently try unlocking the noun with the matching key of the noun.

A room can be scouted or unscouted. A room is usually unscouted. After going: now the location is scouted; continue the action. [1]

[And now an even fancier flourish. This is because the descriptions occasionally refer to whole areas of the castle (e.g., the courtyard description mentioning the "state rooms", so it would be nice if the game understood these titles as input, as well. The basic principle at work here is to make it as easy as possible to return to any area the player has scene and to automate movement to such a degree that mapping is unnecessary and the space-covering trips of the endgame are easy.]

Understand "go to [any region]" or "walk [around] [any region]" or "search [any region]" as region-seeking. Region-seeking is an action applying to one thing.

Check region-seeking:

if the map region of location is the noun or the map region of the location is in the noun, say "You're already in [the noun]; if you'd like to investigate other rooms, you'll have to be more specific about directions." instead.

Carry out region-seeking:

let the goal be nothing;

repeat with space running through pivotal rooms

begin;

if the map region of the space is the noun, let goal be the space;

if the map region of the space is in the noun, let goal be the space;

end repeat;

while the map region of the location is not the noun and the player is not in the goal

begin;

let heading be the best route from the location to the noun through scouted rooms, using doors;

if heading is not a direction,

let heading be the best route from the location to the noun through scouted rooms, 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])[line break]";

try going heading;

if the player is not in the destination, rule fails;

end while.

A room can be pivotal or outlying. A room is usually outlying. The Courtyard is pivotal. The Scarlet Gallery is pivotal. The State Rotunda is pivotal. The Rose Garden is pivotal. The Bellroom is pivotal. The Parlor is pivotal. The Drawbridge is pivotal. The Upper Bulb is pivotal. The Central Crypt is pivotal.

[This system works only because every room in the map has at least one region, and because regions are not stacked more than two deep; otherwise, a more complicated method would have had to be devised.]

Note

[1]. This is necessary because we want the automatic movement to plot a course through areas the player has passed through, whether or not they were dark at the time. Rooms only traversed in darkness are not marked 'visited', so we have to find another way to keep track: 'scouted' means that the player has entered the room at some time or other but may or may not have seen it in the light. Without this restriction, the pathfinder might take the player through rooms not yet explored, which would be less fun; and it might also try to go through off-limits regions.