Inform keeps picking the wrong objects

Hi everyone.

So, I’ve created a new action called drying it with:

Drying it with is an action applying to two visible things. Understand "dry [something] with [something]" and "dry off [something] with [something]" and "dry [something] off with [something]" as drying it with.

The point of this action is so the player can dry off after taking a bath.

Before taking a bath, the player has to put their clothes in a laundry chute and put their other items on a shelf in the bathing area.

The problem comes with after the bath. The player is much more likely to say something like “dry off” or “dry” than “Dry me with towel.” But when the player eliminates the noun and the second noun, the game assumes the player wants to dry the shelf with the shelf.

I have tried every variation of “does the player mean” in order to force Inform to choose the player as the noun and the towel as the second noun, but I cannot get it to work. The closest I can get is getting Inform to suggest drying the shelf with the towel.

I have also tried “Rule for supplying a missing noun” and “Rule for supplying a missing second noun” but came up with nothing.

I’ve read the documentation on both “does the player mean” and “rule for supplying” and I don’t fully understand the difference between them. I have a code for casting a spell that uses the latter and it works perfectly:

Casting it at is an action applying to one spell and one visible thing. Understand "cast [spell] at/on [something]" or "cast [spell]" or "[spell]" or "[spell] [something]" or "use [spell] on [something]" or "use [spell]" as casting it at. Rule for supplying a missing second noun when casting: now the second noun is the location.

For what it’s worth, this is a bathroom in public housing in a fantasy setting, so there are several bathing stalls in the one bathroom, each with its own (separately named) shelf and towel. Each shelf is also a kind of supporter I created called a “shelfy” and each towel a kind of thing I created called a “towely”.

I first tried making the rules universal to apply to all of the bathing areas, but when that didn’t work, I tried focusing on just one, but I still got nowhere.

But my end goal is to get to the point where after the bath, the player can say “dry off” or “dry” and Inform will reach for the player and the visible “towely” as the missing nouns while ignoring the visible “shelfy.”

I hope that all makes sense.

Thank you in advance!

1 Like

Try:

Does the player mean drying the actor with: it is likely.
Does the player mean drying the actor with a towely: it is very likely.

this works because:

(i) when first considering the noun:
‘drying <something that is not the actor> with’ scores 2000 ‘does the player mean’ points (for ‘possible’)
but ‘drying <the actor> with’ scores 3000 DTPM points (for likely).

consequently, the actor (usually the player) gets picked as the noun.

THEN, having established that the player is the noun,

(ii) now considering the second noun:
‘drying <the actor> with <something other than a towely>’ scores 3000 DTPM points for ‘likely’
but ‘drying <the actor> with <a towely>’ scores 4000 DTPM points for ’ very likely’

If you just write

Does the player mean drying the actor with a towely: it is very likely.

then

when the noun is being considered, the second noun is as yet unknown, so the DTPM phrase doesn’t match at all and the highest scoring object in scope is the shelf, primarily because
(i) it’s not undescribed, like the player is
(ii) it’s directly in the location, unlike the towel which is on a shelf.

If you write:

Does the player mean drying the actor with: it is very likely.
Does the player mean drying the actor with a towely: it is very likely.

then

the noun gets allocated as the actor, because every action where the actor is the noun scores 4000 DTPM points, but because of this the more specific DTPM phrase involving the towely doesn’t score any more DTPM points than any other phrase with the actor as noun, so again the shelf wins out as the second noun for the same reasons as above.

To instead invoke the ‘supplying a missing [second] noun’ rules, you need to have Understand phrases with the relevant noun and/or second noun missing too.

So in this case:

Understand "dry [something]" and "dry off [something]" and "dry [something] off" as drying it with.
Understand "dry" and "dry off" as drying it with.
3 Likes

PS, you probably want your things to be touchable, not visible (which, unintuitively, in action declarations means ‘anywhere, whether it can be seen or not’. So:

Drying it with is an action applying to two touchable things.

or just

Drying it with is an action applying to two things.

(‘touchable’ here being the default)

1 Like

In fuller answer to your question- 'What is the difference between the ‘supplying a [second] noun’ rules and the ‘does the player mean’ rules:

The ‘does the player mean’ rules apply when the parser is trying to decide between a number of plausible actions that could match what the player has typed. This can happen for one of two reasons: (i) the player has typed something which matches the name of more than one thing in scope (such as ‘towel’ when there is both a ‘red towel’ and a ‘green towel’ in scope). If Inform is unable to decide between them even after considering DTPM rules, it will ask the player to clarify with ‘Which do you mean, the red towel or the green towel?’
(ii) the player has just missed out a noun or second noun altogether from what they have typed.
In this second case, if and only if what the player has typed matches a shortened ‘Understand’ phrase, Inform will first try to insert a [second] noun supplied by the relevant rule.
Failing that, Inform tries to fill in the blanks through ‘inferring’ what the player meant by considering and scoring every thing in scope for the [second] noun, including the DTPM rulebook scores. If Inform is unable to make a decision because there is a tie for ‘top score’ Inform will ask something like, perhaps in response to ‘dry off’, 'What do you want to dry off?.

3 Likes

Thank you so much! I really appreciate your help. I hope to work on this tomorrow morning, so I’ll update you on how it goes.

I do have one more question. I noticed you used the word “actor.” I’ve been using the word “player.” Is there a difference?

2 Likes

I think isn’t a bad idea adding a “DTPM calculator” to inform IDE…

Best regards from Italy,
dott. Piergiorgio.

What do you mean? A breakdown of how disambiguation scores are calculated? I have an enhanced parser trace extension that does that, if you’re interested.

1 Like

‘actor’ is a variable available while an action is being processed that holds whoever it is who is performing the action. That will usually be the same as the ‘player’ variable, but after a command like ‘Bob, dry off’ the ‘actor’ would be Bob.

Should you need to know who the ‘actor’ was when an action is no longer being processed, or in a rule which sits outside the action-processing rules and therefore doesn’t have access to the ‘actor’ variable, you can use ‘the person asked’, which is equivalent. For a normal command the player is ‘the person asked’, but in the example above, it would be Bob.

A caveat: if in an action rule preamble you use ‘actor’ or ‘the actor’- e.g. ‘Instead of the actor jumping…’ this doesn’t mean the ‘actor’ variable, and in fact means ‘anyone performing the action except the player’. Conversely, and by a special rule, the exact wording ‘Instead of an actor…’ does mean absolutely anyone performing the action, including the player.

4 Likes

Actions can be done by NPCs, in which case they are the actor. Technically, then, actions in Inform have an actor, and can have a noun and a second noun.

3 Likes

That makes sense, thanks.

And thanks so much for your earlier help! It worked perfectly! The drying situation is fixed. I added the object-less commands to the ‘understand’ phrase and then added the ‘supplying a [second] noun rules’ and that cleared it right up.

I was also able to use that knowledge to tighten up the bathing command and make it much more natural.

Before it applied to nothing. “Bathe” makes sense on its own, but I had to add synonyms like “clean me” and “wash me” etc.

Now it applies to a noun, which allows the player to bathe/wash/clean things other than the player, but the parser will assume he means the player when no noun is specified.

So, thanks again!

2 Likes

Ah, I hadn’t considered NPC’s performing actions, but that makes sense. Thanks!

1 Like

You’re welcome. I’m all for more natural bathing.

3 Likes

Ha! It also allows for some opportunities for humor as the player can try bathing other people now.

I don’t see it mentioned above, but another common approach to this sort of thing is to create a new action with its own grammar lines, but just redirect it to the main one. So, for example, you might have:

Bathing is an action applying to one thing.
Understand "bathe [thing]" or "give [thing] a bath" as bathing.

Bathing aimlessly is an action applying to nothing.
Understand "bathe" or "take a bath" as bathing aimlessly.
Instead of bathing aimlessly: try bathing the player.

(Code untested!)

The advantage of this sort of approach is that you get to customize the grammar more explicitly – see the extra synonyms that would have been hard to add with just one verb – though I think it can interfere with some of the noun-supplying behaviour that other folks have explained above.

3 Likes

But basically the scoring, although technically additive, is really done in ‘levels’, by which I mean that even if all the lower levels are scored maximally, the combined score can’t exceed the score allocated for the level above.

The levels are:

A higher DTPM level>>Not undescribed>>Held by the player for things preferably held/In the location for things not preferably held>>In the location for things preferably held/held by the player for things not preferably held>>Neither held nor in the location, but also not a compass direction>>Not scenery>>Not the actor>>Has the expected gender/number/animate descriptors.

The exception to this is that there is another either-or scoring category, Good/Bad, which reflects whether the object in question fulfils some basic requirement for the proposed action, e.g. for ‘Drop’ that the object is carried by the actor.

If the parser is looking for one definite object (rather than multiple or an indefinite number of objects), and only one object is ‘Good’, then the parser chooses that object and doesn’t proceed to scoring.

Otherwise, all obejcts are considered, scored and ranked, regardless of whether they are Good or Bad, but Good objects receive a bonus score equivalent to 1 difference between DTPM levels (i.e. 1000 points).

With the two-action solution, the “supplying a missing noun” activity is simply irrelevant. It doesn’t run and you don’t need it.

1 Like

The ideal one should one where you paste your code, parse the various “likely”, “unlikely” and so on, then calculate the resulting score; this should help in avoid the frequent mistakes stemming from more or less manual calculation of the scoring; but other, simpler method perhaps are more feasible, the issue is that the disambiguation scoring isn’t always easy to calculate in advance.

Best regards from Italy,
dott. Piergiorgio.

I still don’t fully understand the problem you’re describing. DTMP scoring is straightforward- it’s always 0 for very unlikely, 1000 for unlikely, 2000 for possible, 3000 for likely, 4000 for very likely. These scores are different enough from each other that the DTPM score will always override any other scoring (all other possible scores combined are less than 1000- with the Good/Bad exception descibed above, the effect of which is that being Good effectivley promotes you up one DTPM rank- or if already very likely, to a rank above the usual highest DTPM rank of very likely; perhaps extremely likely?).*

Consequently, the issue with DTPM is not calculating scoring, but deciding whether a particular conditional DTPM action pattern will apply or not at the various stages of constructing an inferred action- i.e. whether it matches when considering the inferred first noun, whether it matches when considering the inferred second noun…

As I alluded to before, this is also the case for lower levels of scoring than DTPM. The way the scores are allocated, it’s not really a scoring system but a ranking system, in which the score allocated for each ranking level exceeds the maximal combined score of all lower ranks combined. Thus, for example, a descibed object will always be chosen over an undescribed object with the same DTPM score, a described object directly in the location will always be chosen over a described object not directly in the location with the same DTPM score, etc. etc., regardless of all other considerations.

* EDIT: Historical note- at one time the Good/Bad score was 500, not 1000, such that a DTPM score would also always override a Good/Bad score, but for some reason at some time this was changed

3 Likes