42. Add containers, pronouns and more rooms carefully
Once the little game works, you can extend it. Keep each new grammar feature explicit so a sentence cannot accidentally trigger a different puzzle.
| Feature | State and parsing you need |
|---|---|
| LOOK IN BOX | A container-open flag, contents list and a grammar branch that preserves IN. |
| PUT FUSE IN BOX | A two-object rule with IN; checks for carried source and accessible container. |
| USE IT ON DOOR | A saved or session last-noun value; a rule to resolve IT before validating ownership. |
| Which key? | A candidate list, a pending question and a way to accept the answer as the next input. |
| More rooms | An exit map with explicit destination/spawn and optional conditions. |
| Several commands in one line | A queue and a rule that stops processing when a reply, room change or failure requires attention. |
Do not reuse the ignored-word list to erase IN and then try to infer a container action afterward. Preserve meaningful separators until the grammar has used them.
The example handles one command at a time. It rejects or fails to match extra phrases instead of promising general natural-language understanding. Keep that limit in the game’s HELP text so players know how to talk to it.
