Intervisibility and Doors

I am trying to make some rooms intervisible and I noticed a large problem with the intervisibility rules in the Rock Garden example: They don’t work on doors.

Apparently moving a room into scope doesn’t move the doors into scope, even if the rooms on both sides of the door are all connected. Understandable, but it makes those rules useless if any of the connected rooms have doors in them.

Any way I can modify these rules (or make up new ones) so that the player can look at doors in connected rooms?

I looked at this, and I can’t figure it out. It seems to have something to do with how Inform does path-finding.

I created a garden gate between Rock Garden East and Rock Garden West, and got the problem you’ve described. I then added this code to the rule for reaching inside a room, right after “let way be the best route…”:

if the way is a door:
say “Boinnnggg!”;

This statement never fires, so way isn’t a door … but it’s not a direction either. Turns out it’s nothing. If I change that to “if the way is nothing”, my say statement fires off.

I suppose this behavior could be modified by writing a test inside of the rule for reaching inside of the room – a test that would look at whether target and location are joined by a door. You’d have to create a new relation – call it “door-joining” or something like that. I’ll try it later if I have time.

–JA

You can do it this way – but my solution is not general, it’s specific to the example. I’m not sure how best to generalize it. I’ve created a general door-joining relation, but my rule has to check the specific locations and supply a direction.

[code]Section 1 - General Rules

Intervisibility relates rooms to each other in groups. The verb to be connected with implies the intervisibility relation.

Definition: a room is inter-visible if it is connected with more than one room.

Door-joining relates rooms to each other in groups. The verb to be door-joined to implies the door-joining relation.

After deciding the scope of the player when the location is an inter-visible room:
repeat with other place running through rooms which are connected with the location:
unless the other place is the location, place the other place in scope.

Rule for reaching inside a room (called target) which is connected with the location:
let way be the best route from the location to the target;
if the way is nothing:
if the location is door-joined to the target:
say “(first heading through the gate)[command clarification break]”;
if the player is in Rock Garden East:
try going west;
otherwise:
try going east;
if the player is in the target, allow access;
otherwise deny access;
if the way is not a direction:
say “You can’t get over to [the target] from here.”;
deny access;
say “(first heading [way])[command clarification break]”;
try going way;
if the player is in the target, allow access;
otherwise deny access.

After looking when the location is an inter-visible room:
repeat with other place running through rooms which are connected with the location:
if the other place is not the location, describe locale for other place.

Section 2 - The Scenario

Rock Garden West is a room. Rock Garden East is a room. Rock Garden East contains a rake. Rock Garden West contains a bench and a maple leaf. The bench is an enterable supporter.

The rock garden gate is a door. It is open. It is west of Rock Garden East and east of Rock Garden West.

Rock Garden West is connected with Rock Garden East. Rock Garden West is door-joined to Rock Garden East.

Test me with “get rake / drop rake / sit on bench / get rake”.[/code]

I’m not so much concerned with the rooms connected by doors as I am with the door itself: It isn’t being placed in scope, so you can’t examine it or automatically move towards it. Like so:

[code]Rock Garden West is west of Rock Garden East. Rock Garden East contains a rake. Rock Garden West contains a bench and a maple leaf. The bench is an enterable supporter.

Rock Garden West is connected with Rock Garden East. The House is connected with Rock Garden East.

The gate is east of Rock Garden East and west of the House. It is a door.

Test me with “examine gate / open gate”.[/code]

Notice that the gate isn’t even mentioned when you’re in Rock Garden West. Thus the rules aren’t much good, because there is something in Rock Garden East that you can’t see or examine. My instinct is to just manually move the doors in scope:

After deciding the scope of the player when the location is an inter-visible room: repeat with other place running through rooms which are connected with the location: unless the other place is the location, place the other place in scope; repeat with other door running through all doors which are adjacent to the location: unless the other place is the location, place the other door in scope.

But that doesn’t work (apparently a door is neither “in” nor “adjacent to” a room it’s connected to?).

Path-finding doesn’t use doors as a default; see Writing with Inform 6.14:

So if I’ve understood your example correctly, the best route is “nothing” because you can’t get here from there without going through a door.

That’s right. This has nothing to do with pathfinding, which isn’t being used to determine scope in the Rock Garden example, and everything to do with the implementation of doors. A door is an object that has to be in two places at once, so it is handled by Inform like a backdrop. When the player moves to a new location, Inform does a bit of housekeeping and moves to that location all the backdrop and door objects that ought to be visible from there; it removes all the ones that should not.

One way around this is to use an implementation of doors that treats each side of a door individually. It is fiddly, but the Deluxe Doors extension does that.

Another way is manually to revise the placement of door backdrops. Backdrops are normally moved at the start of play and then also during “carry out going…”. You’d want to call your rule from the carry out rulebook but make sure it was placed late in the process, like so:

[code]When play begins:
follow the door updating rule.

Last carry out an actor going somewhere:
follow the door updating rule.

This is the door updating rule:
repeat with item running through doors:
unless the item is in the location:
if the front side of the item is a room which is connected with the location:
move item to the front side of the item;
otherwise if the back side of the item is a room which is connected with the location:
move item to the back side of the item.[/code]

This solution is more compact than the two door-halves solution. I’ve tested it lightly and it seems to work, though it’s possible there are complications I haven’t thought of.