Helping the Inform7 parser disambiguate rooms

Hello all,

I’m currently learning Inform7 by writing a story, and I’ve recently added the possibility to navigate to other (visited) rooms via the built-in “best route” feature. It all works as expected, BUT I cannot seem to help the parser disambiguate between similar-named rooms when the context would be meaningful.

The idea is that when the location is adjacent to one of the ambiguous room, I would expect the generic name to select the adjacent room, and only when I’m “far” from either I’d want the parser to ask.

The way I tried to do this is with

Understand "the/-- bathroom" as the main bathroom when the location is the living room.
Understand "the/-- bathroom" as the parents' bathroom when the location is the parents' bedroom.

but apparently the parser does not make use of these “understanding” to disambiguate?

Here’s a minimal test case including my room movement implementation:

Include Exit Lister by Gavin Lambert.

Section 1 - Listing and moving between rooms

[ We assume the character knows where the rooms are, so we can always list them. ]
The unvisited room memory rule is not listed in the room memory rules.

[ First of all, put adjacent rooms in scope after everything else ]
After deciding the scope of the player while going (this is the place the room in scope while going rule):
	repeat with compass-direction running through exit-listable directions:
		place the room compass-direction from the location in scope, but not its contents.

Understand "go to/in/into/-- [a room]" as going.

Check an actor going (this is the find a route rule):
	if the noun is a room:
		if the location is the noun:
			say "I'm in [the noun] already." instead;
		while the location is not the noun:
			let compass-direction be the best route from the location to the noun, using even locked doors;
			if compass-direction is not a direction:
				say "I don't know how to go there." instead;
			otherwise:
				let the next location be the room compass-direction from the location;
				if the next location is the noun:
					say "(going [compass-direction])";
					convert to the going action on the compass-direction;
				otherwise if the next location is unvisited:
					say "Are you in a hurry? I haven't shown you the rest of the house yet. How can you help me if we miss something important about the rooms I haven't shown you yet? 'Haste makes waste!' Let's go slowly and carefully at first." instead;
				otherwise:
					say "(first going [compass-direction] through [the next location])[command clarification break]";
					silently try going compass-direction;
					if the location is not the next location:
						break;
		if the location is not the noun:
			stop the action.

The find a route rule is listed before the determine map connection rule in the check going rules.

Section 2 - The map

The foyer is a room.

The living room is west of the foyer.

The main bathroom is west of the living room.
Understand "the/-- bathroom" as the main bathroom when the location is the living room.

The parents' bedroom is east of the foyer.

The parents' bathroom is east of the parents' bedroom.
Understand "the/-- bathroom" as the parents' bathroom when the location is the parents' bedroom.

Section 3 - Testing

Test me with "go to the living room / go to the parents['] bedroom / go to the bathroom / go to the parents['] bathroom / go to the living room / go to the bathroom"

I guess I could just make an Understand line for the whole go to/in/into/– the/– bathroom line but that seems like overkill. Am I missing something?

Your “understand” lines don’t add anything because “bathroom” can already be understood as referring to either bathroom. “Understand” only determines which interpretations are possible, not which are chosen; that’s the job of a separate disambiguation mechanism.

I’m not at a computer to test it, but does it work if you add something like this?

Does the player mean going to the main bathroom when the location is the living room: it is likely.

2 Likes

Oh, thanks for the clarification on the understanding thing.

I have tried replacing it with the does the player mean you suggest but apparently it didn’t help disambiguate but then I realized that the action is just going, not going to!

Does the player mean going the main bathroom when the location is the living room: it is very likely. does solve the problem, thank you very much. Although it reads horribly so I should probably make a new action for this? 8-D

I think you could probably write it more generally:

Does the player mean going an adjacent room: it is very likely.
3 Likes

Oh I like that!