I’m now working on the no-such-thing object that Zarf mentioned. During testing it came out that I need this.
Here’s test output for the ‘drop cube’ command when you’re not holding any, but they are all on the floor. In that case the parser will ask which one you mean and next the interpreter will tell you you’re not holding the object.
[code]XVAN transcript for: test ambiguities
version: 1.0
Room
look
Room
There’s a red man with a mission here.
There’s a blue man with a mission here.
There’s a green man with a mission here.
There’s a red bowl here.
There’s a green bowl here.
There’s a blue bowl here.
There’s an orange bowl here.
There’s a red cube here.
There’s a green cube here.
There’s a blue cube here.
There’s an orange cube here.
There’s a purple cube here.
i
You are carrying:
Nothing, you are empty-handed.
drop cube
Which cube do you mean?
The red cube, the green cube, the blue cube, the orange cube or the purple cube?
red
One must hold something before it can be dropped…
transcript
Turning off transcript mode.[/code]
Of course it shouldn’t ask which cube, but should say something like you’re not holding a cube or similar message.
I think this is where the no-such-thing object can help out:
- in step 1 when generating all possible action records, generate 1 extra with no-such-thing.
- the no-such-thing record gets a default score of 1, the others get 0.
- now with ‘drop cube’ when not holding any, after applying the disambiguation rules, the no-such-thing record will have won because nobody got their score updated. The rules will assign points when the object is being held.
- next, the interpreter will get the no-such-thing record from the parser. It should check on this particular value and then print something like ‘you have no such thing to drop’.
I’m building it right now and I’m pretty sure this will work for user input with 1 noun, like get . But what if there are 2 nouns, like attach to and you need to be holding them both?