Command not understood: a problem with command ambiguity

I have two understand rules in my game which share a word, and something a bit odd is happening as a result. Here are the relevant bits of code (though why they are what they are is going to be a bit opaque without a lot of context):

[code]Dancingwards is a direction.

Clubbing is a region.

Entranceway is a room in Clubbing. Dancing is a room in Clubbing. at the Bar is a room in Clubbing. at the Seats is a room in Clubbing. Second Hallway is a room.

Dancing is dancingwards of Entranceway. Dancing is dancingwards of at the Bar. Dancing is dancingwards of at the Seats. Dancing is dancingwards of Dancing.

The dance is a backdrop in Entranceway.

Understand “dance”, “dancing”, “the dance” and “the dancing” as dancingwards when the player is in Clubbing.

The boy is a man.

The loners are scenery in at the Seats. After examining the loners for the first time: now the boy is in at the Seats.

Understand “dance with [the boy]” as taking when the boy is in at the Seats.[/code]

When the player types “dance” it ought to make the player go dancingwards to dancing, unless the boy is in at the Seats. But instead we get the “command not understood” error: “I didn’t understand that sentence”. When the boy is in at the Seats, however, the taking action takes place fine. (I had originally made a new action called “dancing with” with the command “dancing with [something]”, but that caused the same problem, so I tried something else: no dice.)

I tried to muddle through this and wondered if, as detailed in Documentation 16.21-22, the ‘Understand “dance with [the boy]”’ rule was taking precedence over the ‘Understand “dance”’ rule, so I tried adding

Does the player mean going dancingwards: it is very likely. Does the player mean taking: it is unlikely.

but that didn’t seem to do anything.

I’ve been at it for a while now, and I’m completely stumped: I’m not sure what’s going on (turning on RULES and ACTIONS listing while playing yielded no information), let alone how to fix it. Part of the problem is that I can’t work out what rule causes the “command not understood” error to be printed. How does one figure out such things? And does anyone have a solution to this problem? Any help much appreciated.

This line doesn’t do what you think it’s doing. “Dance” and variations are being understood as an object (in this case, a direction), not as an action. In other words, if you type: GO DANCE, then Inform will read this as “GO DANCINGWARDS”, but it won’t do anything with it at all if there is otherwise no action being triggered. And that’s the problem you were running into.

What you really want is:

However, Inform can’t quite do that, because it doesn’t allow for a full stored action (roughly, verb + noun) in that situation, only the bare action name–so, you can only get as far as “going” with this syntax. (Might be worth a suggestion, though, to try to get the functionality expanded to include stored actions.)

Anyway, here’s one way to do what you’re after:

[code]Understand “dance”, “dancing”, “the dance” and “the dancing” as going when the player is in Clubbing.

Rule for supplying a missing noun while going when the player is in Clubbing:
if the player’s command matches the regular expression “danc”:
now the noun is dancingwards.

The block vaguely going rule is not listed in the for supplying a missing noun rules.[/code]


Actually, I was partly misunderstanding what you were saying, I think. You were trying to simply create “dance” as a synonym for “dancingwards”, so that it would be understood by Inform as a command for going of the form “[direction]”. And it should indeed work that way, but (as you suggested), your use of “dance with” as a synonym for taking is interfering. Given this, the solution I posted above should be regarded as a workaround, not as the “right” way to do it.

I’m not sure if there’s a way to force Inform to get Inform to prefer your synonym-turned-grammar (dance as synonym for dancingwards as short form for going) to your straight-up grammar (dance with as a synonym for taking). Maybe someone else could help with that. (By the way, the TRACE debugging command will show that Inform is only trying to match against the taking special case grammar.)


I’m glad to know that my analysis of what’s causing the problem seems to be correct, and the workaround you provided seems to work. Better still, I seem to understand why the workaround works. So thank you.

Now I just wish I understood why the problem’s occurring! An extra datum: with the workaround in place, “dance” still produces “I didn’t understand that sentence” when there is no location dancingwards of the current location, with TRACE again showing that in that case Inform is only trying to match against the taking special case grammar.

One thing which might help me understand: can you tell me how to find out what rule causes the “command not understood” error to be printed? I only know that that’s the name of the error by searching through David Fisher’s Custom Library Messages; I’m sure there must be a better way.

That error comes out of the “printing a parser error” activity; it’s labelled the “didn’t understand error”.

The basic problem is that the parser doesn’t handle directions consistently with other verbs. Workarounds are all you’re going to get, I’m afraid.

I would drop the idea of using “dance” as a direction. Handle “dance/dancing” as an special action (not “going”, that’s awkward); and then understand “go dance” and “go dancing” as the same action. (The carry-out rules for the action will have to be location-specific, obviously.)

Thanks for the clarification. Is this the kind of thing I should send in as a bug report, or is this limitation well understood?

Aye, I think a rewrite of this whole bit is a good idea. Though this is actually part of a clumsy attempt to allow navigation in a particular area by room name. However, I’ve now rediscovered the “go by name” ideas in 16.7, so I reckon that’s the best option.

If you specifically want the functionality of the going action, it seems you could redirect a newly defined going dancing action to the action of going dancingwards:

[code]Going dancing is an action applying to nothing.
Understand “dance”, “dancing”, “the dance”, “go dance”, “go dancing” and “the dancing” as going dancing.

Check going dancing when the actor is not in Clubbing: say “There’s no dancing going on around here.” instead.
Carry out going dancing when the actor is in Clubbing: try going dancingwards instead.

Don’t know what draw-backs there may be, though.

Instead of dancing when the player is in clubbing:
   move the character to the dance.

Your original source, for all its flaws, is poetically written. I like your style.

I think Zarf is right, though, that this is the hard way to do things. If it were my game, I’d probably have a place called “dance floor”, give it normal compass connections, and then add some sugar so that all of your grammars will be understood in addition to the normal directions. But maybe this isn’t the sort of club that has a place referred to as a “dance floor…”