## version 2/111127 by Aaron Reed

Book - Approaches by Emily Short

[Version 4]

A person can be staid or hurrying. A person is usually staid.
A room can be proper-named or improper-named.

Before refusing keys for something (this is the tell the preface blocked doors with path walked rule):
say "[path-walked so far]".

Rule for refusing keys for a door (called locked-thing) when the player is hurrying (this is the tell the player when blocked at a door rule):
say "Unfortunately, you find you lack a key that fits [the locked-thing].[no line break]";
rule succeeds.

A person has a list of objects called the path so far.
A person has a list of indexed text called described motion.

To say path-walked so far:
carry out the describing path activity with the player.

Describing path of something is an activity.

Rule for describing path of someone (called the worker) (this is the default path description rule):
if the number of entries in the path so far of the worker is greater than 0:
if the location is not the noun:
let N be the number of entries in the described motion of the worker;
let last movement be entry N in the described motion of the worker;
truncate the described motion of the worker to (N - 1) entries;
if N is 1:
otherwise:
say "[The worker] go[es] [described motion of the worker]";
if N is greater than 2, say ", before heading";
say " [the last movement]. [run paragraph on]";
otherwise:
say "[The worker] go[es] [described motion of the worker]. [run paragraph on]";
clear path-walked for worker.

To clear all/the/-- path-walked for (worker - a person):
truncate the described motion of the worker to 0 entries;
truncate the path so far of the worker to 0 entries.

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

Approaching is an action applying to one visible thing.

Check an actor approaching (this is the can't approach our current location rule):
if the noun is the location of the actor:
if the actor is the player, say "You're already in [the location].";
stop the action;

The approach-finding rules are a rulebook.

The approach-heading is an object that varies.
The approach-destination is a room that varies.
The final destination is a room that varies.

A first approach-finding rule (this is the recording destination rule):
now the final destination is the noun.

An approach-finding rule (this is the approach-heading selection rule):
now approach-heading is the best route from the location to the noun through visited rooms, using doors;
if approach-heading is not a direction:
now approach-heading is the best route from the location to the noun through visited rooms, using even locked doors;

if approach-heading is not a direction:
say "You can't think how to get there from here.";
rule fails;

An approach-finding rule (this is the find outcome rule):
now approach-destination is the room approach-heading from the location;

An approach-finding rule (this is the actual approach movement rule):

An approach-finding rule (this is the abort movement if held up rule):
if the location is not the approach-destination:
clear the path-walked for the player;
now the player is staid;
say conditional paragraph break;
try looking;
rule fails;

Carry out going while the player is hurrying (this is the creating a path history rule):
let approach-destination-name be indexed text;
let approach-destination-name be "[the approach-destination]";
let X be the number of entries in the path so far of the player;
if X is greater than 1:
let previous direction be entry (X - 1) in the path so far of the player;
if the previous direction is the approach-heading, now adverb is "again ";
let N be indexed text;
if approach-destination is proper-named:
otherwise:
add N to the described motion of the player;

An approach-finding rule (this is the final approach success rule):
rule succeeds.

Carry out approaching (this is the default approaching rule):
clear path-walked for the player;
now the player is hurrying;
let initial location be the location;
while the location is not the noun:
if rule failed:
now the player is staid;
stop the action;
now the player is staid;

Carry out someone approaching (this is the other character approach rule):
clear path-walked for the actor;
let initial location be the location of the actor;
while the location of the actor is not the noun:
now approach-heading is the best route from the location of the actor to the noun, using doors;
if approach-heading is not a direction:
now approach-heading is the best route from the location of the actor to the noun, using even locked doors;
if approach-heading is not a direction:
stop the action;
now approach-destination is the room approach-heading from the location of the actor;
try the actor going the approach-heading;
if the location of the actor is not the approach-destination:
stop the action.

Report approaching when the location is the noun and the number of entries in the path so far of the player is greater than 1 (this is the describe overall path on arrival rule):
carry out the describing path activity with the player;
say paragraph break;