When you have multiple hits for noun1 and in order to resolve it you need noun2, which also happens to have multiple hits, then that’s an issue. Even worse when resolving noun2 also depends on noun1. In that case we need sort of a trial and error approach
I was thinking about simply trying all possible combinations of hits for noun1 and noun2: iterate through all possible hits for noun2 and in each iteration try all possible hits for noun1. Apply the parsing rules for each combination, assign the scores and hope that one combination wins.
So, for the fruits we would have 9 possibilities, each with initially, say, 10 points
put lime in orange, 10
put coconut in orange, 10
put orange in orange, 10
put lime in coconut, 10
put coconut in coconut, 10
put orange in coconut, 10
put lime in lime, 10
put coconut in lime, 10
put orange in lime, 10
Now we need some parsing rules that the author can enter in your framework
We can never put something in itself, so
if equal(noun1, noun2) then score(-100)
This gives (sorted):
put lime in orange, 10
put coconut in orange, 10
put lime in coconut, 10
put orange in coconut, 10
put coconut in lime, 10
put orange in lime, 10
put orange in orange, -90
put coconut in coconut, -90
put lime in lime, -90
We can only put something in a container
if testflag(noun2.f_container) then
score(+10)
if testflag(noun2.f_open) then
score(+5) # extra bonus when the container is also open
endif
endif
This gives:
put lime in coconut, 25
put orange in coconut, 25
put lime in orange, 10
put coconut in orange, 10
put coconut in lime, 10
put orange in lime, 10
put coconut in coconut, -80
put orange in orange, -90
put lime in lime, -90
Now there are 2 winners.
We could add another parsing rule which would rule out the orange
if testflag(noun1.f_in_harry_nilssen_lyrics) and testflag(noun2.f_in_harry_nilssen_lyrics) then score(+5)
If we forget about this last rule then we get:
[code]
put fruit in fruit
What do you want to put in the coconut, the lime or the orange?
lime[/code]
After this point, the scores don’t matter anymore because we have unique hits for noun1 and noun2. If the player would have typed ‘coconut’ instead of lime or orange then ‘put coconut in coconut’ would have been sent to the interpreter which would have thrown an error.
I know a little but about Inform 7 (I dissected the Bronze sources for my project). If you make the coconut a container, wouldn’t Inform be able to figure it out to the level of lime or orange?
For the pedestal and bust scenario I think “take bust from pedestal” is pretty hopeless. Unless we use the Hugo approach and set a flag for the last examined object and hope it’s either a bust or a pedestal.
Options are:
take venus from blue pedestal, 10
take cupid from blue pedestal, 10
take venus from red pedestal, 10
take cupid from red pedestal, 10
Rule1: if testflag(noun2.f_supporter) then score(+5)
Rule2: if testflag(noun1.f_takeable) then score(+5)
Rule3: if testflag(noun1.f_last_examined) or testflag(noun2.f_last_examined) then score(+1)
Rule 4: if contains(noun2, noun1) then score(+5)
After rule 1:
take venus from blue pedestal, 15
take cupid from blue pedestal, 15
take venus from red pedestal, 15
take cupid from red pedestal, 15
After rule 2:
take venus from blue pedestal, 20
take cupid from blue pedestal, 20
take venus from red pedestal, 20
take cupid from red pedestal, 20
Suppose they examined the blue pedestal last, then after rule 3
After rule 3:
take venus from blue pedestal, 16
take cupid from blue pedestal, 16
take venus from red pedestal, 15
take cupid from red pedestal, 15
And after rule 4:
take venus from blue pedestal, 21
take cupid from red pedestal, 20
take cupid from blue pedestal, 16
take venus from red pedestal, 15
But honestly, if I were in the shrine and someone would instruct me to take the bust from the pedestal, I would kindly ask them to be a little more specific…