Duplicate objects bug

I have a bug related to duplicate objects (identical objects, as in the “Early Childhood” examples) where the player tries to perform an action on one of the objects, but the game performs the action on more than one object. So far I haven’t found the source of the problem, and I’m not sure what elements of the code are likely to be at fault. I tried pasting just the relevant parts of the code into a new project to try to isolate the problem, but the new project didn’t have the bug (presumably I’m missing something). So below I’m pasting a transcript and just a few lines of the code.

(This may be a little spoilery if you haven’t played Delphina’s House.)

[spoiler]Trying to put a stone in the basin sometimes puts just one stone in, and sometimes puts several stones in, depending on how you enter the command. I want it to put in only one stone, unless the player explicitly makes it plural. Here’s the transcript:

[code]>i
You are carrying:
five softly glowing stones
a map
some fish crackers

put softly in middle basin
You drop the softly glowing stone into the medium silver basin, watching it sink into the luminous blue light-water, where it remains unchanged. After watching it for a time, you reach into the fountain and pick up the stone once more.

put softly glowing in middle basin
softly glowing stone: You drop the softly glowing stone into the medium silver basin, watching it sink into the luminous blue light-water, where it remains unchanged. After watching it for a time, you reach into the fountain and pick up the stone once more.
softly glowing stone: You drop the softly glowing stone into the medium silver basin, watching it sink into the luminous blue light-water, where it remains unchanged. After watching it for a time, you reach into the fountain and pick up the stone once more.
softly glowing stone: You drop the softly glowing stone into the medium silver basin, watching it sink into the luminous blue light-water, where it remains unchanged. After watching it for a time, you reach into the fountain and pick up the stone once more.
softly glowing stone: You drop the softly glowing stone into the medium silver basin, watching it sink into the luminous blue light-water, where it remains unchanged. After watching it for a time, you reach into the fountain and pick up the stone once more.
softly glowing stone: You drop the softly glowing stone into the medium silver basin, watching it sink into the luminous blue light-water, where it remains unchanged. After watching it for a time, you reach into the fountain and pick up the stone once more.

put softly glowing stone in middle basin
softly glowing stone: You drop the softly glowing stone into the medium silver basin, watching it sink into the luminous blue light-water, where it remains unchanged. After watching it for a time, you reach into the fountain and pick up the stone once more.
softly glowing stone: You drop the softly glowing stone into the medium silver basin, watching it sink into the luminous blue light-water, where it remains unchanged. After watching it for a time, you reach into the fountain and pick up the stone once more.
softly glowing stone: You drop the softly glowing stone into the medium silver basin, watching it sink into the luminous blue light-water, where it remains unchanged. After watching it for a time, you reach into the fountain and pick up the stone once more.
softly glowing stone: You drop the softly glowing stone into the medium silver basin, watching it sink into the luminous blue light-water, where it remains unchanged. After watching it for a time, you reach into the fountain and pick up the stone once more.
softly glowing stone: You drop the softly glowing stone into the medium silver basin, watching it sink into the luminous blue light-water, where it remains unchanged. After watching it for a time, you reach into the fountain and pick up the stone once more.

rules
Rules tracing now switched on. Type “rules off” to switch it off again, or “rules all” to include even rules which do not apply.

[Rule “Before reading a command” applies.]

actions
[Rule “ordinary checking for content rule” applies.]
[Rule “Numbered Disambiguation Choices strip closing parenthesis rule” applies.]
[Rule “avoid odd errors but allow numbers rule” applies.]
[Rule “zap out of world actions for in-hint rule” applies.]
[Rule “t1 to t 1 rule” applies.]
[Rule “declare everything initially unmentioned rule” applies.]
Actions listing on.

[Rule “Before reading a command” applies.]

put softly in middle basin
[Rule “ordinary checking for content rule” applies.]
[Rule “Numbered Disambiguation Choices strip closing parenthesis rule” applies.]
[Rule “avoid odd errors but allow numbers rule” applies.]
[Rule “zap out of world actions for in-hint rule” applies.]
[Rule “t1 to t 1 rule” applies.]
[Rule “declare everything initially unmentioned rule” applies.]
[inserting the softly glowing stone into the medium silver basin]
[Rule “silently announce items from multiple object lists rule” applies.]
[Rule “set pronouns from items from multiple object lists rule” applies.]
[Rule “before stage rule” applies.]
[Rule “instead stage rule” applies.]
[Rule “Instead of inserting a glowing stone ( called GS ) into a bowl ( called B )” applies.]
You drop the softly glowing stone into the medium silver basin, watching it sink into the luminous blue light-water, where it remains unchanged. After watching it for a time, you reach into the fountain and pick up the stone once more.
[inserting the softly glowing stone into the medium silver basin - failed]

[Rule “A first turn sequence rule” applies.]
[Rule “every turn stage rule” applies.]
[Rule “check if we’re in hints rule” applies.]
[Rule “A last turn sequence rule” applies.]
[Rule “notify score changes rule” applies.]
[Rule “Before reading a command” applies.]

put softly glowing stone in middle basin
[Rule “ordinary checking for content rule” applies.]
[Rule “Numbered Disambiguation Choices strip closing parenthesis rule” applies.]
[Rule “avoid odd errors but allow numbers rule” applies.]
[Rule “zap out of world actions for in-hint rule” applies.]
[Rule “t1 to t 1 rule” applies.]
[Rule “declare everything initially unmentioned rule” applies.]
[inserting the softly glowing stone into the medium silver basin]
[Rule “silently announce items from multiple object lists rule” applies.]
softly glowing stone: [Rule “set pronouns from items from multiple object lists rule” applies.]
[Rule “before stage rule” applies.]
[Rule “instead stage rule” applies.]
[Rule “Instead of inserting a glowing stone ( called GS ) into a bowl ( called B )” applies.]
You drop the softly glowing stone into the medium silver basin, watching it sink into the luminous blue light-water, where it remains unchanged. After watching it for a time, you reach into the fountain and pick up the stone once more.
[inserting the softly glowing stone into the medium silver basin - failed]
[inserting the softly glowing stone into the medium silver basin]
[Rule “silently announce items from multiple object lists rule” applies.]
softly glowing stone: [Rule “set pronouns from items from multiple object lists rule” applies.]
[Rule “before stage rule” applies.]
[Rule “instead stage rule” applies.]
[Rule “Instead of inserting a glowing stone ( called GS ) into a bowl ( called B )” applies.]
You drop the softly glowing stone into the medium silver basin, watching it sink into the luminous blue light-water, where it remains unchanged. After watching it for a time, you reach into the fountain and pick up the stone once more.
[inserting the softly glowing stone into the medium silver basin - failed]
[inserting the softly glowing stone into the medium silver basin]
[Rule “silently announce items from multiple object lists rule” applies.]
softly glowing stone: [Rule “set pronouns from items from multiple object lists rule” applies.]
[Rule “before stage rule” applies.]
[Rule “instead stage rule” applies.]
[Rule “Instead of inserting a glowing stone ( called GS ) into a bowl ( called B )” applies.]
You drop the softly glowing stone into the medium silver basin, watching it sink into the luminous blue light-water, where it remains unchanged. After watching it for a time, you reach into the fountain and pick up the stone once more.
[inserting the softly glowing stone into the medium silver basin - failed]
[inserting the softly glowing stone into the medium silver basin]
[Rule “silently announce items from multiple object lists rule” applies.]
softly glowing stone: [Rule “set pronouns from items from multiple object lists rule” applies.]
[Rule “before stage rule” applies.]
[Rule “instead stage rule” applies.]
[Rule “Instead of inserting a glowing stone ( called GS ) into a bowl ( called B )” applies.]
You drop the softly glowing stone into the medium silver basin, watching it sink into the luminous blue light-water, where it remains unchanged. After watching it for a time, you reach into the fountain and pick up the stone once more.
[inserting the softly glowing stone into the medium silver basin - failed]
[inserting the softly glowing stone into the medium silver basin]
[Rule “silently announce items from multiple object lists rule” applies.]
softly glowing stone: [Rule “set pronouns from items from multiple object lists rule” applies.]
[Rule “before stage rule” applies.]
[Rule “instead stage rule” applies.]
[Rule “Instead of inserting a glowing stone ( called GS ) into a bowl ( called B )” applies.]
You drop the softly glowing stone into the medium silver basin, watching it sink into the luminous blue light-water, where it remains unchanged. After watching it for a time, you reach into the fountain and pick up the stone once more.
[inserting the softly glowing stone into the medium silver basin - failed]

[Rule “A first turn sequence rule” applies.]
[Rule “every turn stage rule” applies.]
[Rule “check if we’re in hints rule” applies.]
[Rule “A last turn sequence rule” applies.]
[Rule “notify score changes rule” applies.]
[Rule “Before reading a command” applies.]

[/code]

A few relevant lines of code:

Brightness is a kind of value. The brightnesses are softly, faintly, brightly, and mixed. A glowing stone is a kind of thing. A glowing stone has a brightness. The brightness of a glowing stone is usually softly. Understand the brightness property as describing a glowing stone.[/spoiler]

Any ideas? I’m not sure how, or where in the process, Inform decides to apply an action to multiple objects vs. just one.

With tracing set to level 5, the differences between parsing the two commands seems to begin here. Differences are (mostly) bolded. I’m not any closer to figuring out what it all means, though–why it decides on a definite object for the first command, but not the second command.

First command: put softly in middle basin:

Pass 1: 1 Pass 2: 1 Pass 3: 0
Matched (1)
Trying the softly glowing stone (1202249) at word 2
Parse_name called
Pass 1: 1 Pass 2: 1 Pass 3: 0
Matched (1)
Trying the softly glowing stone (1202185) at word 2
Parse_name called
Pass 1: 1 Pass 2: 1 Pass 3: 0
Matched (1)
Trying the softly glowing stone (1202121) at word 2
Parse_name called
Pass 1: 1 Pass 2: 1 Pass 3: 0
Matched (1)
Trying the softly glowing stone (1202057) at word 2
Parse_name called
Pass 1: 1 Pass 2: 1 Pass 3: 0
Matched (1)
Trying the map (1197609) at word 2
Parse_name called
Pass 1: 0 Pass 2: 0 Pass 3: 0
Trying the fish crackers (1197641) at word 2
Parse_name called
Pass 1: 0 Pass 2: 0 Pass 3: 0
[ND made 5 matches]
Parse_name called
p1, p2 = 1202313, 1202249
Parse_name called
p1, p2 = 1202249, 1202185
Parse_name called
p1, p2 = 1202185, 1202121
Parse_name called
p1, p2 = 1202121, 1202057
[Adjudicating match list of size 5 in context 0
definite object
Scoring match list: indef mode 0 type 0, satisfying 0 requirements:

 The softly glowing stone (1202313) in yourself : 2176 points

 The softly glowing stone (1202249) in yourself : 2176 points

 The softly glowing stone (1202185) in yourself : 2176 points

 The softly glowing stone (1202121) in yourself : 2176 points

 The softly glowing stone (1202057) in yourself : 2176 points

Parse_name called
p1, p2 = 1202313, 1202249
Parse_name called
p1, p2 = 1202313, 1202185
Parse_name called
p1, p2 = 1202313, 1202121
Parse_name called
p1, p2 = 1202313, 1202057
Grouped into 1 possibilities by name:
The softly glowing stone (1202249) — group 1
The softly glowing stone (1202185) — group 1
The softly glowing stone (1202121) — group 1
The softly glowing stone (1202057) — group 1
Best guess the softly glowing stone (1202313)
[ND returned the softly glowing stone]

[token resulted in success]
[line 5 token 2 word 3 : ‘over’]
[token resulted in failure with error type 1][/code]

Second command: put softly glowing stone in middle basin:

Pass 1: 3 Pass 2: 3 Pass 3: 0
Matched (3)
Trying the softly glowing stone (1202249) at word 2
Parse_name called
Pass 1: 3 Pass 2: 3 Pass 3: 0
Matched (3)
Trying the softly glowing stone (1202185) at word 2
Parse_name called
Pass 1: 3 Pass 2: 3 Pass 3: 0
Matched (3)
Trying the softly glowing stone (1202121) at word 2
Parse_name called
Pass 1: 3 Pass 2: 3 Pass 3: 0
Matched (3)
Trying the softly glowing stone (1202057) at word 2
Parse_name called
Pass 1: 3 Pass 2: 3 Pass 3: 0
Matched (3)
Trying the map (1197609) at word 2
Parse_name called
Pass 1: 0 Pass 2: 0 Pass 3: 0
Matched (0)
Trying the fish crackers (1197641) at word 2
Parse_name called
Pass 1: 0 Pass 2: 0 Pass 3: 0
Matched (0)
[ND made 5 matches]
Parse_name called
p1, p2 = 1202313, 1202249
Parse_name called
p1, p2 = 1202249, 1202185
Parse_name called
p1, p2 = 1202185, 1202121
Parse_name called
p1, p2 = 1202121, 1202057
[Adjudicating match list of size 5 in context 0
indefinite type: plural
number wanted: all
most likely GNAs of names: 4095
Scoring match list: indef mode 1 type 8, satisfying 0 requirements:

 The softly glowing stone (1202313) in yourself : 2176 points

 The softly glowing stone (1202249) in yourself : 2176 points

 The softly glowing stone (1202185) in yourself : 2176 points

 The softly glowing stone (1202121) in yourself : 2176 points

 The softly glowing stone (1202057) in yourself : 2176 points

[token resulted in failure with error type 8][/code]

In general the parser will perform multiple actions like this if the player uses a plural word for a set of indistinguishable objects.

The Kitchen is a room.

A softly glowing stone is a kind of thing.
The player carries five softly glowing stones.

The basin is a container in the Kitchen.

In this example the compiler automatically generates “stones” as the plural of “stone”. So PUT STONE IN BASIN will select one at random, but PUT STONES IN BASIN will put them all in. (The compiler doesn’t do this for “softly” or “glowing”, figuring that those are probably adjectives.)

You could extend this:

Understand "rock" as a softly glowing stone.
Understand "rocks" as the plural of softly glowing stone.

Thanks for the example and explanation. That is more or less how I’d like this to work, except that I’ve got the different brightnesses as values, because they change, so what I’ve got is more like this:

Brightness is a kind of value.
The brightnesses are softly and brightly.

A glowing stone is a kind of thing.
A glowing stone has a brightness.
Understand the brightness property as describing a glowing stone.
Before printing the name of a glowing stone, say "[brightness] ".
Before printing the plural name of a glowing stone, say "[brightness] ".

The Kitchen is a room.
The basin is a container in the Kitchen.
The player carries five glowing stones.

But there must be something somewhere else in the code that’s messing it up, so that the parser interprets “glowing” and “glowing stone” as plural even when the player does not use a plural word. Maybe a conflicting “understand” statement somewhere?

Is it possible you have a line like this somewhere?

Understand "glowing" or "stones" as the plural of glowing stone.

I just tried a stub program with that line and when you try “take glowing” or even “take glowing stone” it takes them all. I guess that once you’ve got one word that can be understand as a plural in there it grabs them all.

Thanks, that’s a good suggestion. I did a search for “as the plural” and didn’t find anything relevant with that exact wording. But I did find this:

Some pre-placed stones are a plural-named thing. The pre-placed stones are a glowing stone. The pre-placed stones have a placement. The placement of the pre-placed stones is placed. The pre-placed stones are mixed. [i.e. mixed brightness] The pre-placed stones are part of the star tile. The printed name of the pre-placed stones is "placed glowing stones".

When I comment this out, the bug goes away. Not sure exactly what the problem is, though. Hmm.

Huh. Well, that narrows down the effect: the line “The pre-placed stones are a glowing stone” causes both “glowing” and “stones” to be marked as plural. The previous declaration of five anonymous glowing stones did not do that.

The same happens even if you write “The silmaril is a glowing stone.” I’m not sure what the compiler logic is here, to treat “glowing” this way only in this case.

To work around this, you have to switch to an artificial class-name:

A glowing-stone is a kind of thing.
Understand “glowing”, “stone” as a glowing-stone.
Understand “stones” as the plural of glowing-stone.

Then the only plural term will be “stones”. (And “glowing-stones”, which the player won’t type, and actually the plural flag gets dropped due to I think an I6 bug.)

That worked great. I think this bug is squashed. Thanks very much!