Problems with using very long object names to help parsing - is there a better way?


As the code below illustrates, I’m using some very long object names, which suit some intangible objects, concepts in fact. In other text the player sees, they are introduced to these concepts, which I then want them to be able to refer to (for simplicity in the below code I’m using ‘examine’ but there is probably going to be some new verb like ‘contemplate’). The advantage of the long names is that the parser recognises all sorts of pieces of them. So for example there is a concept called ‘the dark associations of the scent of the yellow flowers’, and if the player drops out a word that might seem natural to drop (e.g. ‘yellow’) the parser still matches the concept. If I instead give the object a short name and use something like ‘understand “the dark associations of the scent of the yellow flowers” as the flower-concept’, then only the whole phrase is matched by the parser.

But with the long names, I get a different odd problem. Specifically, below, the ‘troubling question’ concept is caught by the parser, but not by the instead rule.

Any suggestions for a better way to do this?

A concept is a kind of thing.
After deciding the scope of the player:
	repeat with C running through concepts:
		place C in scope;

Instead of examining a concept, say "No further thoughts come to you."

There is a concept called the troubling question of your presence in a location with no apparent way out. Instead of examining the troubling question of your presence in a location with no apparent way out: say "Thinking about the troubling question of your presence in a location with no apparent way out."

There is a concept called the dark associations of the scent of the yellow flowers. Instead of examining the dark associations of the scent of the yellow flowers: say "Thinking about the dark associations of the scent of the yellow flowers."

The player is in a room called The Testing Room.

The parser copes with both of these concepts but the instead rule only works for the flowers:

>x dark associations
Thinking about the dark associations of the scent of the yellow flowers.

>x troubling question
No further thoughts come to you.

The problem here isn’t in the parser, but in the compiler being confused by your Instead rule for the troubling question – if you use the ACTIONS and RULES testing commands, you can see that X TROUBLING QUESTION is properly trying to examine the concept, but the instead rule isn’t firing. If you shorten your Instead rule so it says “Instead of examining the troubling question:” rather than using the full, long name, it all should work (I’m not sure exactly what’s going on, but from a bit of testing of dropping out different pieces of the name, the phrase “location with” looks like it might be the source of the issue, potentially because “location” is a word the compiler already knows in a different context?)

I think the compiler-level issues shouldn’t be too hard to avoid if you stick to “there is a concept called [exceedingly long name]” and then just refer to it with a shorter name. I do worry that you will start running into lots of parser-level issues, though, since if all these long-named concepts are always in scope, you’re headed for disambiguation hell unless you use a ton of synonyms to avoid ever using a word more than once. It’d probably be way easier for all involved to just call the object the troubling question, give it the long printed name if relevant, and than write a line like “Understand “troubling question of/-- your/-- presence/-- in/-- a/-- location/-- with/-- no/-- apparent/-- way/-- out/–” as the troubling question.” (The “/–” means the presence of that word is optional, so the player can type or not type any of those and the parser will still understand it’s the troubling question at issue. If you want other pieces of the name to also work, you can write a similar Understand statement to allow that).

If you want to be even more lenient with what the player can type to refer to your longwinded concept, you can break down the ‘Understand’ clause to list all the important words separated by ‘or’, which means, like words given in the name of an object, they can be typed in any number and any order:

Understand “troubling” or "question of/-- " or “your/-- presence” or “in/-- a/-- location with/–” or “no/-- apparent” or “way out/–” as the troubling question.

1 Like

in is one of the special prepositions recognised in rule headings, causing the following phrase to be matched against the location of the player. Since the phrase refers to the concept (it doesn’t care that the first part is “missing”), Inform generates some code requiring that the player be located inside the concept for the Instead rule to trigger.

This is actually a bit peculiar, since a concept is not a room and so never could be a location of the player.

For these sorts of long-winded abstract names, it may be better to make the name in the source code be some explicitly privately-named value (e.g. presense-with-no-exits) and then set its printed name and understand phrases according to how you want it to be displayed, while keeping an entirely unambiguous name in the source text.


You lot rule, thanks so much! There were several things I didn’t understand at all well, and now I do. The ‘Understand “some/-- of/-- these/-- words/-- without/-- needing/-- all/–”’ trick should work nicely. I will have enough concepts that a player may indeed get frequent parser disambiguation requests but in this case I think that’s OK; this will serve for further clues as to what concepts are available.

1 Like

Hmm, in fact there are some serious problems with using ‘Understand “xxx/–”’.

The following code seems to get something stuck in a loop, if the player types, for example, “showme me” (minutes later, no output, lots of computer fan noise).

There is a thing called the troubling question.
Understand "apparent/-- " as the troubling question.
The player is in a room called The Testing Room.

If you “understand” only one word then you shouldn’t add the /-- part. It makes the word optional which doesn’t make sense when there’s only one word. It’s needed only when there’s more than one word in the grammar:

Understand "apparent/-- way out/--" as ...

which makes the words “apparent” and “out” optional so that it matches “apparent way out” or “apparent way” or “way out” or just “way”.

Note that if you have e.g.

Understand "apparent" or "way" or "out" as ...

all those words are already optional as long as at the input contains least one of them (in any order) so there’s no need to use /-- to signify that.

Making every word between a pair of quotes optional in an “Understand” clause means that it also matches no text at all and this might have unpredictable consequences, because it can in theory match any position in anything typed.

Thanks Juhana and Peter. However, this does not explain the problem. In simplifying for illustration I clearly cooked this down too far, sorry, but my real use does not involve single words like this, and you don’t need single words like this to cause the problem. The following code also suffers from it:

There is a thing called the troubling question.

Understand "apparent/-- violent/-- tendencies/--" as the troubling question.

The player is in a room called The Testing Room.

That’s essentially the same issue because the grammar is saying that all words are optional, which means that even input that doesn’t contain any of those words should match the object. What you really want is to match input that contains at least one of those words, which you can get with this:

Understand "apparent violent/-- tendencies/--" as the troubling question.
Understand "apparent/-- violent tendencies/--" as the troubling question.
Understand "apparent/-- violent/-- tendencies" as the troubling question.

But personally I would simply do

Understand "apparent" or "violent" or "tendencies" as the troubling question.

which does the same thing except it doesn’t care about the order of the words, but it’s reasonable that the parser would recognize what the player means even if they don’t use the exact word order.

Yeah, the “or” approach allows more flexibility in parsing what the player types, but given the complexity of the examples that might not be a good thing to use for all the words in the name (especially the common ones like “yellow” or “flowers”) given the high likelihood of parser confusion and player irritation – better I think to require that those words come after saying one of the distinctive ones.

The usefulness of the ‘/–’ notation in combination with ‘or’ syntax arises if you want the player not be irritated by having fully-copied-out phrases including conjunctions, prepositions etc. rejected.

For example, if you say the hamster resembles ‘a golden ball of fluff and fur’ but then say:

Understand “golden” or “ball” or “fluff” or “fur” as the hamster.

the parser will reject ‘examine the golden ball of fluff and fur’ saying ‘I only understood you as far as wanting to examine the hamster’ because it matched “golden ball” as meaning the hamster but then couldn’t match “of”.


Understand “golden” or “ball of/–” or “fluff and/–” or “fur and/–” as the hamster.

will accept ‘Examine golden ball of fluff and fur’ or ‘Examine ball of fur’ or ‘examine ball of fur and fluff’ and numerous other variations.

The trick is to give each ‘important’ or ‘distinctive’ word or word sequence its own ‘or’ phrase in which it is required but combine it with any optional adjectives/prepositions/conjunctions that might reasonably be typed before or after it.

If you have many convoluted names, you might want to avoid giving words like ‘of’ or ‘and’ their own ‘or’ phrases (which would otherwise also allow all the above to be recognised):

Understand “golden” or “ball” or “of” or “fluff” or “and” or “fur” as the hamster.

because, as independent words, they might begin to match an awful lot of things other than the hamster.

Although, having said that, these are words that are unlikely to be typed on their own, and the parser’s methods of finding the best match for what has been typed will therefore usually avoid disambiguation problems through its consideration of the surrounding words- if there is a ‘piece of cake’ in the game, although typing ‘Examine of’ would match the cake and the hamster equally, leading to
‘Which do you mean, the cake or the hamster?’
typing ‘Examine of fur’ or ‘Examine of cake’ will allow the parser to choose correctly without recourse to the player even though ‘of’ matches both.

Indeed, non-descript words such as these are included individually in the list of words Inform searches for matches if they are given as part of the name of something, e.g. ‘In the Lab is an animal called the ball of fluff and fur.’ allows the player to type "Examine of and’ and, since it matches 2 words rather than 1, this will be assumed to refer to the hamster rather than a ‘piece of cake’. Inform assumes that the parser will be able to resolve potential ambiguities in most cases of things the player is in practice likely to type, which will also include more distinctive words.

In short to replicate Inform’s default approach to name matching, list every word separately, including prepositions and conjunctions, in its own ‘or’ phrase:

Understand “word1” or “word2” or “word3”… as the object.


It does, because you’re still making each and every word optional, so it potentially matches every position in every text typed, even if all three of the optional words are absent.

Exhaustive explanations very much appreciated - thanks! Finally I’m getting the hang of this one.

1 Like