Okay, so I’ve come up with two alternative approaches, but I think I still prefer the rulebook-based one. This is fairly different from my previous rulebook-based approach – in fact, it’s written such that one reachability rule handles nearly every case.
Rulebook Version (code)
Include Postures by Emily Short.
Include Auxiliary Phrases by Stefan O'Halloran.
Section 1 - General Mechanics
To reach is a verb. To allow is a verb.
A booster is a kind of supporter.
A booster is usually portable.
A booster is always enterable.
A person can be strong or weak.
A person is usually weak.
Every booster allows standing.
Definition: a person (called they) is boosted:
if they are not on a booster, no;
if they are not standing, no;
yes.
Boosting is an action applying to one thing.
Understand "boost [person]" as boosting.
Understand "hoist [person]" as boosting.
Hoisting relates one person to one person.
The verb to hoist means the hoisting relation.
Instead of an actor dropping someone (called the load) who is hoisted by the actor:
if the holder of the actor is a container or the holder of the actor is a room:
now the load is in the holder of the actor;
otherwise:
now the load is on the holder of the actor;
now the actor is not hoisting the load;
say "[The actor] [set] [the load] back down [on the holder of the actor]."
Check an actor boosting when the actor is weak (this is the weak people can't boost rule):
if the actor is the player:
say "[We]['re] not strong enough." (A);
stop the action.
Carry out an actor boosting (this is the standard boosting rule):
now the actor hoists the noun;
Report an actor boosting (this is the report boosting rule):
say "[The actor] [allow] [us or the noun] to climb onto [regarding the actor][their] shoulders." (A);
Check going when the player is hoisting someone (called the load) (this is the player can't move while boosting rule):
say "Not while carrying [the load]!" (A).
First carry out going when a person (called the passenger) is hoisted by the actor (this is the set down load before going rule):
now the actor is not hoisting the passenger;
if the passenger is the player:
say "[The actor] [set] [us] down." (A);
otherwise:
say "[The actor] [set] down [the passenger]." (B);
[Though the above two rules mean an actor can't go while hoisting, a specific game could choose to disable that rule. So, in that case, allow matching "going by" the person in rules.]
Setting action variables for going when the actor is hoisting someone (called the load) (this is the moving while hoisting is like a vehicle rule):
now the vehicle gone by is the load.
First carry out going when a person (called the helper) is hoisting the player (this is the get off your helper before going rule):
if the noun is not up:
say "(first getting off of [the helper])[command clarification break]" (A);
now the helper is not hoisting the actor;
if the helper hoists the player, stop.
First carry out someone going when a person (called the helper) is hoisting the actor (this is the set them down so they can go rule):
if the noun is not up:
say "[We or the actor] [get] off of [the helper]." (A) instead;
now the helper is not hoisting the actor;
if the helper hoists the actor, stop.
First carry out an actor exiting when a person (called the helper) is hoisting the actor (this is the convert exit to getting off the helper rule):
now the helper is not hoisting the actor;
say "[We or the actor] [get] off of [the helper]." (A) instead;
A person can be tall. A person is usually not tall.
Section 2 - Reach Mechanics
A thing has a number called the access height.
To decide what number is the effective access height of (T - a thing):
[if T is the player, say "checking access height.";]
let height be the access height of T;
[say "native height [height].";]
let H be the holder of T;
while H is a thing:
[if T is the player, say "held by [H].";]
if the access height of H is greater than height:
[if T is the player, say "boosted to [H]'s level.";]
let height be the access height of H;
if H is a booster:
[if T is the player, say "boosted above [H]'s level.";]
increase height by 1;
let H be the holder of H;
if T is a person and T is hoisted by someone (called the helper):
[if T is the player, say "hoisted by [the helper].";]
increase height by 1;
if the helper is tall:
[if T is the player, say "[the helper] is tall.";]
increase height by 1;
decide on height.
To decide what number is the minimum access height of (P - a person):
let n be the effective access height of P;
if P is wearing the extensible claw, decide on n - 1;
decide on n.
To decide what number is the maximum access height of (P - a person):
let n be the effective access height of P;
if P is tall, increase n by 1;
if P is wearing the extensible claw, decide on n + 1;
decide on n.
Check reachability is an object based rulebook. The check reachability rules have outcomes in reach (success) and out of reach (failure). Reporting failure to reach something is an activity on objects
To decide whether (P - a person) can reach (T - a thing):
now the person reaching is P;
follow the check reachability rules for T;
if the outcome of the rulebook is the out of reach outcome:
if the player can see P:
carry out the reporting failure to reach activity with T;
no;
yes.
To decide whether (P - a person) cannot/can't reach (T - a thing):
if P can reach T, no;
yes.
An action-processing rule (this is the checking reach rule):
if the current action is going and the door gone through is a door:
if the actor cannot reach the door gone through, stop the action;
if the action requires a touchable noun:
if the actor cannot reach the noun, stop the action;
if the action requires a touchable second noun:
if the actor cannot reach the second noun, stop the action.
For reporting failure to reach something (called the item) (this is the standard report reach failure rule):
say "[We or the person reaching] [can't reach] [regarding the item][those]." (A).
For reporting failure to reach an open door (called the portal) while going (this is the report open door reach failure rule):
say "[We or the person reaching] [can't reach] the opening of [the portal]." (A).
For reporting failure to reach a closed door (called the portal) while going (this is the report closed door reach failure rule):
say "[We or the person reaching] [can't reach] [the portal]." (A).
Check reachability for someone hoisted by the person reaching (this is the ignore reachability for hoisted people rule):
in reach.
Check reachability for someone hoisting the person reaching (this is the ignore reachability for the person hoisting rule):
in reach.
Check reachability for something enclosed by the person reaching (this is the ignore reachability for held items rule):
in reach.
Check reachability for a door (called the portal) when the direction of the portal from the location of the person reaching is down (this is the doors to the down always have access height zero rule):
if the minimum access height of the person reaching is at most 0:
in reach;
out of reach.
Check reachability for something (called the item) (this is the standard reachability rule):
let min be the minimum access height of the person reaching;
let max be the maximum access height of the person reaching;
[say "[min] ≤ [effective access height of the particular possession] ≤ [max].";]
if the effective access height of the item is between min and max:
in reach;
out of reach.
The stand up before going rule does nothing when the noun is up.
The can't travel in what's not a vehicle rule does nothing when the noun is up.
Section 3 - Scenario
The Shaft is a room.
Bob is a tall strong person in the Shaft.
The chair is a fixed in place booster in the Shaft.
The shelf is a supporter in the Shaft. The access height of the shelf is 2.
On the shelf is silver key. The silver key unlocks the box.
The box is a transparent closed openable locked container in the Shaft. The access height of the box is 3.
In the box is an extensible claw. The extensible claw is wearable.
The trapdoor is a door. It is up from the Shaft and down from the Surface. It has access height 4.
Yourself carries a rope and a strength pill. The strength pill is edible.
Persuasion rule for asking Bob to try doing something: rule succeeds.
The block giving rule does nothing.
Carry out an actor giving: now the second noun carries the noun.
To tie is a verb.
Check tying the rope to something:
say "[We] [tie] [the rope] to [the second noun].";
rule succeeds.
After eating the strength pill:
now the player is strong;
say "[We] [feel] stronger!".
Rulebook Version (sample transcript)
Shaft
You can see a trapdoor, Bob, a chair, a shelf (on which is silver key) and a box (closed) (in which is an extensible claw) here.
>take key
You can't reach that.
>tie rope to key
You can't reach that.
>take Bob
I don't suppose Bob would care for that.
>take chair
That's fixed in place.
>open box
You can't reach that.
>stand on chair
You are now standing on the chair.
>take key
You can't reach that.
>open box
You can't reach that.
>Bob, stand on chair
Bob is now standing on the chair.
>Bob, take key
Bob picks up silver key.
>Bob, open box
Bob can't reach that.
>boost Bob
You're not strong enough.
>eat pill
You feel stronger!
>boost Bob
You allow Bob to climb onto your shoulders.
>Bob, open box
Bob is unable to do that.
>Bob, unlock box with key
Bob unlocks the box.
>Bob, lock box with key
Bob locks the box.
>drop Bob
You set Bob back down on the chair.
>Bob, boost me
Bob allows you to climb onto his shoulders.
>Bob, give me key
Bob gives silver key to you.
>give Bob key
You give silver key to Bob.
>Bob, give me key
Bob gives silver key to you.
>up
You can't reach the trapdoor.
>unlock box with key
You unlock the box.
>take claw
The box isn't open.
>open box
You open the box.
>take claw
Taken.
>open trapdoor
You can't reach that.
>wear claw
You put on the extensible claw.
>open trapdoor
You open the trapdoor.
>take off claw
You take off the extensible claw.
>up
You can't reach the opening of the trapdoor.
>give claw to Bob
You give the extensible claw to Bob.
>up
You can't reach the opening of the trapdoor.
>Bob, wear claw
Bob puts on the extensible claw.
>up
You can't reach the opening of the trapdoor.
>Bob, take off claw
Bob takes off the extensible claw.
>Bob, give me claw
Bob gives the extensible claw to you.
>wear claw
You put on the extensible claw.
>up
Surface
You can see a trapdoor here.
>
Room Version (code)
"Room Based" by Stefan O'Halloran
Include Postures by Emily Short.
Include Auxiliary Phrases by Stefan O'Halloran.
Section 1 - General Mechanics
To reach is a verb. To allow is a verb.
A booster is a kind of supporter.
A booster is usually portable.
A booster is always enterable.
A person can be strong or weak.
A person is usually weak.
Every booster allows standing.
Definition: a person (called they) is boosted:
if they are not on a booster, no;
if they are not standing, no;
yes.
Boosting is an action applying to one thing.
Understand "boost [person]" as boosting.
Understand "hoist [person]" as boosting.
Hoisting relates one person to one person.
The verb to hoist means the hoisting relation.
Instead of an actor dropping someone (called the load) who is hoisted by the actor:
if the holder of the actor is a container or the holder of the actor is a room:
now the load is in the holder of the actor;
otherwise:
now the load is on the holder of the actor;
now the actor is not hoisting the load;
say "[The actor] [set] [the load] back down [on the holder of the actor]."
Check an actor boosting when the actor is weak (this is the weak people can't boost rule):
if the actor is the player:
say "[We]['re] not strong enough." (A);
stop the action.
Carry out an actor boosting (this is the standard boosting rule):
now the actor hoists the noun;
Report an actor boosting (this is the report boosting rule):
say "[The actor] [allow] [us or the noun] to climb onto [regarding the actor][their] shoulders." (A);
Check going when the player is hoisting someone (called the load) (this is the player can't move while boosting rule):
say "Not while carrying [the load]!" (A).
First carry out going when a person (called the passenger) is hoisted by the actor (this is the set down load before going rule):
now the actor is not hoisting the passenger;
if the passenger is the player:
say "[The actor] [set] [us] down." (A);
otherwise:
say "[The actor] [set] down [the passenger]." (B);
[Though the above two rules mean an actor can't go while hoisting, a specific game could choose to disable that rule. So, in that case, allow matching "going by" the person in rules.]
Setting action variables for going when the actor is hoisting someone (called the load) (this is the moving while hoisting is like a vehicle rule):
now the vehicle gone by is the load.
First carry out going when a person (called the helper) is hoisting the player (this is the get off your helper before going rule):
if the noun is not up:
say "(first getting off of [the helper])[command clarification break]" (A);
now the helper is not hoisting the actor;
if the helper hoists the player, stop.
First carry out someone going when a person (called the helper) is hoisting the actor (this is the set them down so they can go rule):
if the noun is not up:
say "[We or the actor] [get] off of [the helper]." (A);
now the helper is not hoisting the actor;
if the helper hoists the actor, stop.
First carry out an actor exiting when a person (called the helper) is hoisting the actor (this is the convert exit to getting off the helper rule):
now the helper is not hoisting the actor;
say "[We or the actor] [get] off of [the helper]." (A);
A person can be tall. A person is usually not tall.
Section 2 - Reach Mechanics
An area is a kind of region.
To decide what number is the minimum access height of (P - a person):
let n be 0;
if P is on a booster, increase n by 1;
if P is hoisted by someone, increase n by 1;
if P is hoisted by someone tall, increase n by 1;
if P is wearing the extensible claw, decrease n by 1;
decide on n.
To decide what number is the maximum access height of (P - a person):
let n be 0;
if P is on a booster, increase n by 1;
if P is hoisted by someone, increase n by 1;
if P is hoisted by someone tall, increase n by 1;
if P is tall, increase n by 1;
if P is wearing the extensible claw, increase n by 1;
decide on n.
After deciding the scope of a person (called they):
if they are regionally in an area (called it):
repeat with R running through rooms regionally in it:
[say "[R] is in scope.";]
place the contents of R in scope.
Rule for reaching inside a room (called the destination):
[say "Reaching into [the destination].";]
let min be the minimum access height of the person reaching;
let max be the maximum access height of the person reaching;
let here be the location of the person reaching;
let the height difference be zero;
while here is not the destination:
[say "--Checking [here].";]
let thataway be the best route from here to the destination;
if thataway is up and the height difference is at least zero:
increase the height difference by 1;
otherwise if thataway is down and the height difference is at most zero:
decrease the height difference by 1;
let here be the room thataway from here;
[say "--Height difference is [height difference].";]
[say "--Min reach is [min] and max reach is [max].";]
if height difference < 0 and height difference < min:
[say "--Fails - too low";]
make no decision;
if height difference > 0 and height difference > max:
[say "--Fails -- too high";]
make no decision;
[say "--Succeeds";]
allow access.
The reach tester is a thing.
Check an actor going a direction (called thataway):
let here be the location of the actor;
if here is in an area (called there):
let R be the room thataway from here;
if R is regionally in there:
while the room thataway from R is regionally in there:
let R be the room thataway from R;
now the reach tester is in R;
if the actor cannot touch the reach tester:
say "[We] [can't reach] that exit." instead.
Carry out an actor going (this is the determine regional map connection rule):
let temp be the room gone from;
[say "Going from [room gone from]...";]
follow the determine map connection rule;
if the room gone from is regionally in an area (called there):
while the room gone to is a room and the room gone to is regionally in there:
now the room gone from is the room gone to;
[say "...through [room gone from]...";]
follow the determine map connection rule;
[say "...to [room gone to].";]
now the room gone from is temp;
[This should really be "The determine regional map connection substitutes for the determine map connection in the check going rulebook." but that doesn't work.]
The determine map connection rule is not listed in the check going rulebook.
The determine regional map connection rule is listed before the can't go that way rule in the check going rules.
The stand up before going rule does nothing when the noun is up.
The can't travel in what's not a vehicle rule does nothing when the noun is up.
Section 3 - Scenario
ShaftBottom, ShaftOne, ShaftTwo, ShaftThree, ShaftCeiling are rooms.
The Shaft is an area. ShaftBottom, ShaftOne, ShaftTwo, ShaftThree, ShaftCeiling are in Shaft.
ShaftCeiling is above ShaftThree. ShaftThree is above ShaftTwo. ShaftTwo is above ShaftOne. ShaftOne is above ShaftBottom.
Bob is a tall strong person in ShaftBottom.
The chair is a fixed in place booster in ShaftBottom.
The shelf is a supporter in ShaftTwo.
On the shelf is silver key. The silver key unlocks the box.
The box is a transparent closed openable locked container in ShaftThree.
In the box is an extensible claw. The extensible claw is wearable.
The trapdoor is a door. It is up from ShaftCeiling and down from the Surface.
Yourself carries a rope and a strength pill. The strength pill is edible.
Persuasion rule for asking Bob to try doing something: rule succeeds.
The block giving rule does nothing.
Carry out an actor giving: now the second noun carries the noun.
To tie is a verb.
Check tying the rope to something:
say "[We] [tie] [the rope] to [the second noun].";
rule succeeds.
After eating the strength pill:
now the player is strong;
say "[We] [feel] stronger!".
Room Version (sample transcript)
ShaftBottom
You can see Bob and a chair here.
>take key
You can't reach into ShaftTwo.
>tie rope to key
You can't reach into ShaftTwo.
>take Bob
I don't suppose Bob would care for that.
>take chair
That's fixed in place.
>stand on chair
You are now standing on the chair.
>take key
You can't reach into ShaftTwo.
>open box
You can't reach into ShaftThree.
>Bob, stand on chair
Bob is now standing on the chair.
>Bob, take key
Bob picks up silver key.
>Bob, open box
Bob is unable to do that.
>boost Bob
You're not strong enough.
>eat pill
You feel stronger!
>boost Bob
You allow Bob to climb onto your shoulders.
>Bob, unlock box with key
Bob unlocks the box.
>drop Bob
You set Bob back down on the chair.
>Bob, boost me
Bob allows you to climb onto his shoulders.
>Bob, give me key
Bob gives silver key to you.
>give Bob key
You give silver key to Bob.
>Bob, give me key
Bob gives silver key to you.
>lock box with key
You lock the box.
>unlock box with key
You unlock the box.
>up
You can't reach that exit.
>open box
You open the box.
>take claw
Taken.
>up
You can't reach that exit.
>wear claw
You put on the extensible claw.
>Bob, close box
Bob is unable to do that.
>close box
You close the box.
>open trapdoor
You open the trapdoor.
>take off claw
You take off the extensible claw.
>up
You can't reach that exit.
>wear claw
You put on the extensible claw.
>take off claw
You take off the extensible claw.
>give claw to Bob
You give the extensible claw to Bob.
>Bob, wear claw
Bob puts on the extensible claw.
>up
You can't reach that exit.
>Bob, take off claw
Bob takes off the extensible claw.
>Bob, give me claw
Bob gives the extensible claw to you.
>wear claw
You put on the extensible claw.
>up
Surface
You can see a trapdoor here.
>
Notes:
- Section 1 in both examples is exactly the same.
- Those examples include a private extension that defines a bunch of phrases, so they’re not quite fully standalone examples that you can paste in and run. The specific phrases used are shown below (I think that’s all of them):
Auxiliary Phrases Excerpt
To say us or the (culprit - an object):
if the culprit is the player, say "[us]";
otherwise say "[the culprit]".
To say We or the (culprit - an object):
if the culprit is the player, say "[We]";
otherwise say "[The culprit]".
To say in/on the (table - a supporter):
say "on [the table]".
To say in/on the (box - a container):
say "in [the box]".
To say in/on the (T - a thing):
say "[the T]".
To decide whether (N - a number) is between (min - a number) and (max - a number), exclusive or low exclusive or high exclusive:
let real-min be min;
let real-max be max;
if max < min:
let real-min be max;
let real-max be min;
if exclusive or low exclusive:
increase real-min by 1;
if exclusive or high exclusive:
decrease real-max by 1;
decide on whether or not real-min <= N and N <= real-max.
Does anyone see anything wrong with either of these approaches?
The room-based one was actually easier than I expected, but it has the downside of exploding the total number of rooms… and I didn’t finish working out how to make descriptions work in a sensible manner (it would need to show all items in the same “area” region).
So I think I still prefer a rulebook-based approach. This new rulebook-based approach works better than the old one though, and seems to be fine for NPCs.