Section - Ghost Following Actions
The most recent action is a stored action that varies.
The next most recent action is a stored action that varies.
The third most recent action is a stored action that varies.
Every turn:
now the third most recent action is the next most recent action;
now the next most recent action is the most recent action;
now the most recent action is the current action;
if the action name part of the most recent action is the keyless locking action: [if the player just typed "lock door" we want to have the ghost try locking it with the key]
now the action name part of the most recent action is the locking it with action;
now the second noun part of the most recent action is the iron key;
otherwise if the action name part of the most recent action is the keyless unlocking action: [ditto for "unlock door"]
now the action name part of the most recent action is the unlocking it with action;
now the second noun part of the most recent action is the iron key;
otherwise if the action name part of the most recent action is the turning action and the noun part of the most recent action is a door: [it's hard to keep track of whether the action succeeded if we redirect a turning action to an opening action, so we just convert turning to opening here]
now the action name part of the most recent action is the opening action;
otherwise if the noun part of the most recent action is the hidden-key: [and if the player searched the bench by typing "x something," we'll just have the ghost search the bench]
now the action name part of the most recent action is the searching action;
now the noun part of the most recent action is the bench;
now the actor part of the third most recent action is the ghost;
now the request part of the third most recent action is true;
if the ghost is on-stage:
now ghost spontaneously acting is true;
try the third most recent action;
now ghost spontaneously acting is false.
Ghost spontaneously acting is a truth state that varies.
Persuasion rule: if ghost spontaneously acting is true, persuasion succeeds.