Parsing errors with ambiguity and no preposition

I have run across a very strange bug while working on Scroll Thief: if there is an Understand line which contains two object tokens without a preposition between them, and the player types a command which is ambiguous for the first one, the command will not be parsed.

Specifically, I’m running into problems with the Understand line “point [something preferably held] [direction]”. In the game there are a small red sphere and a small blue sphere. If the player tries to “point sphere east” in the presence of both spheres, the game will not ask for disambiguation, and instead just fail to parse the action.

This doesn’t happen if there’s a preposition in there (e.g. “point sphere at east” works fine), but the “point sphere east” phrasing is more natural, and I can’t find a good way to detect it specifically. It also doesn’t happen if the second object is the ambiguous one. “Point sphere” on its own asks for clarification on the second noun, but parses the noun correctly.

Does anyone know what causes this, or how I could fix it?

Not seeing this in a pared-down situation:


The Kitchen is a room. "You are in a kitchen."

A palantir is a kind of thing.
A red sphere is a palantir in the Kitchen.
A blue sphere is a palantir in the Kitchen.

Pointing it at is an action applying to one thing and one visible thing.

Report pointing it at:
	say "Point [noun] at [second noun]."

Understand "point [something preferably held] [direction]" as pointing it at.

(My first guess is that a problem shows up in the presence of noun-first grammar lines.)

Further testing reveals that this is tied to Disambiguation Control by Jon Ingold.

Include Disambiguation Control by Jon Ingold.

The Kitchen is a room. "You are in a kitchen."

A palantir is a kind of thing.
A red sphere is a palantir in the Kitchen.
A blue sphere is a palantir in the Kitchen.

Pointing it at is an action applying to one thing and one visible thing.

Report pointing it at:
	say "Point [noun] at [second noun]."

Understand "point [something preferably held] [direction]" as pointing it at.

Parser trace level 6 dumps:
[rant=Disambig Control]>point sphere east
[ “point” point / “sphere” sphere / “east” east ]
[Parsing for the verb ‘point’ (1 lines)]

[line 0 * held noun=Routine(345156) → A77_pointing_it_at]
[line 0 token 1 word 2 : held]
[Object list from word 2]
[NounDomain called at word 2
seeking definite object
[DSA on yourself with reason = 0 p1 = 0 p2 = 0]
Trying yourself (597010) at word 2
Parse_name called
Pass 1: 0 Pass 2: 0 Pass 3: 0
[DSA on the red sphere with reason = 0 p1 = 0 p2 = 0]
Trying the red sphere (597106) at word 2
Matched (1)
Match with quality 1
Match added to list
[DSA on the blue sphere with reason = 0 p1 = 0 p2 = 0]
Trying the blue sphere (597138) at word 2
Matched (1)
Match with quality 1
Match added to list
[DSA on No-object with reason = 0 p1 = 0 p2 = 0]
Trying No-object (597042) at word 2
[ND made 2 matches]
[ND informed]

the red sphere…?

the blue sphere…?
[DSA on yourself with reason = 0 p1 = 0 p2 = 0]
[DSA on the red sphere with reason = 0 p1 = 0 p2 = 0]
[DSA on the blue sphere with reason = 0 p1 = 0 p2 = 0]
[DSA on No-object with reason = 0 p1 = 0 p2 = 0]
0 possible continuation nouns(Failed to match follow-on words. Moving to next line.)
[token resulted in failure with error type 5]
You can’t see any such thing.[/rant]
[rant=Vanilla]>point sphere east
[ “point” point / “sphere” sphere / “east” east ]
[Parsing for the verb ‘point’ (1 lines)]

[line 0 * held noun=Routine(326789) → A77_pointing_it_at]
[line 0 token 1 word 2 : held]
[Object list from word 2]
[NounDomain called at word 2
seeking definite object
[DSA on yourself with reason = 0 p1 = 0 p2 = 0]
Trying yourself (574631) at word 2
Parse_name called
Pass 1: 0 Pass 2: 0 Pass 3: 0
[DSA on the red sphere with reason = 0 p1 = 0 p2 = 0]
Trying the red sphere (574695) at word 2
Matched (1)
Match with quality 1
Match added to list
[DSA on the blue sphere with reason = 0 p1 = 0 p2 = 0]
Trying the blue sphere (574727) at word 2
Matched (1)
Match with quality 1
Match added to list
[ND made 2 matches]
[Adjudicating match list of size 2 in context 1
definite object
Scoring match list: indef mode 0 type 0, satisfying 0 requirements:

 The red sphere (574695) in the Kitchen : 2156 points

 The blue sphere (574727) in the Kitchen : 2156 points

Grouped into 2 possibilities by name:
The red sphere (574695) — group 1
The blue sphere (574727) — group 2
Unable to choose best group, so ask player.]
Which do you mean, the red sphere or the blue sphere?[/rant]

I think I’ve found the problem now. But could someone better-versed in the I6 parser internals please explain to me the difference between calling SearchScope(actor,actors_location,NOUN_TOKEN) and SearchScope(actors_location,actor,NOUN_TOKEN)? Replacing the first with the second in one place in Disambiguation Control fixes this problem, but I’m afraid I might break something else.

The difference is only a matter of order – the first argument is searched first.

(This is what the Parser.i6t documentation implies. There may be subtleties.)

Excellent. This relies on one of those subtleties: the compass directions are only placed in scope if the first argument is the actors_location.

Eek. Apologies for that, it does sound messy (so to be clear, the issue is not with [verb] [noun] [noun] but specifically with [verb] [noun] [compass direction].)

I suspect that the “right” solution for DC would be to get it to include compass directions regardless of the order of the arguments, since it should know what they are and try to understand them in any context. I may get a chance to look at this, I may not; but either way, let me know if your change here has any nasty side-effects.

(And also, ooh, I had no idea anyone was using DC, so that’s cool; glad it helped-until-now.)

cheers
jon

I haven’t run into any problems yet with the change, once it’s been more thoroughly tested I’ll post the extension itself. (It’s just that one line change at the moment.)

And yes, this only affects commands of the form VERB NOUN DIRECTION. Probably why it didn’t rear its head until now.