Circumventing supplying a missing noun

If I want to entirely make it impossible that the supplying a missing noun activity were ever to start, how would I go about it? Sometimes when I ask questions, people misunderstand my intention for my application, and suggest alternatives to the approach entirely, but I would like to really explore doing specifically what I am asking here, rather than discussing why it is a bad idea or something like that, if possible.

To clarify what i am trying to do, I want to intercept commands that lack a valid noun, but should have one, and try to apply contextual logic that will figure out the noun for the player. In the absolute worst-case scenario, this logic will choose the player himself, if absolutely no nouns other than the player exist in the location. This doesn’t mean that the resulting action must succeed… if the action is impossible with the noun selected, the action will still result in failing to do whatever it is with said noun, but I never want no noun to be selected if a command to take an action requiring a noun is entered.


>take blarg

should never result in the response “You must supply a missing noun”. I don’t mean to change this library response, I mean this parser error should never occur.

Instead, I have other plans for ultimately changing the player’s command into something that will try to figure out what that action could apply to.

The beginnings of this, I thought, might be this:

After reading a command:
	if the noun is nothing:

The problem with this, is that there are lots of commands that aren’t supposed to have nouns, like taking inventory, for example. This is problematic for me, because I don’t know how to differentiate what action is being attempted before it is attempted… that is, how to determine what the action is during the reading a command activity. Is there an easy way to determine what action is being attempted during the reading a command phase? Is there a better way to accomplish what I am trying to do here (again, to actually accomplish what I outlined above, not a different thing to code with a totally different premise).

Edit: I just realized this might be confusing, because usually the parser error is the can’t see any such thing error, but I’ve already accounted for that, never letting that one happen, and instead parsing the text of the command even if there are no things that match the noun… so the next parser error encountered is the one in question here, the supplying a missing noun error. I sometimes forget the other pieces upstream I’ve already changed…

I think I’d be inclined to do something like:

Understand "take" as taking without a noun supplied.

Taking without a noun supplied is an action applying to nothing.

Check an actor taking without a noun supplied (this is the delicious cake rule):
	if the actor can see the delicious cake and the delicious cake is not enclosed by the actor:
		convert to the taking action on the delicious cake.

(but I haven’t tried compiling that particular chunk of code.)


After reading a command rules are run before the parser fills in the noun, second noun, and action, so you can’t meaningfully refer to them at that point.

I’m confused by your other mini-examples as well. Typing “take blarg” would normally give the response “Taken.” or “You can’t see any such thing.”, not “you must supply a missing noun”–there is a noun there, even if it’s not a valid one. Are you referring to the case when the command is simply “take” and there are multiple portable objects in the location?

Supplying a missing second/-- noun is run only if the player types a command with no noun, which matches a grammar line without a [something] (or [things] etc.) token, which redirects to an action which requires a noun (or second noun).
If the second of those conditions, specifically, is not met, the game will supply a noun if there is only one available, or prompt the player to complete their command. This is up to the “does the player mean” rulebook, not the “supplying a missing second/-- noun” activity.

I’m going to have to suggest a different approach, because your description of your intent is somewhat self-contradictory. If you really want to remove that activity, just remove the few grammar lines which leave out the noun or second noun (the only one that comes to mind is “go”).

If you want to change the default behavior when the player leaves out the noun, however, there are a couple ways you could do this:

  1. Duplicate all the grammar lines from the Standard Rules and find-and-replace [something] (and [things] and [things inside] and such) with an empty string. Then put your rules to decide which thing should be taken or dropped or eaten or whatever in the for supplying a missing second/-- noun rulebooks, e.g. “Rule for supplying a missing noun when eating: if the number of carried edible things is one, decide on a random carried edible thing.”

  2. Put your rules to decide which thing should be taken or dropped or eaten or whatever in the does the player mean rules, e.g. “Does the player mean eating something edible: it is very likely.” can result in this:
    You see an apple and a rock here.

(the apple)

Out of these, the second is probably easier and is more in line with what the Standard Rules use these rulebooks for. See WI 18.32 for more information.

EDIT: What Roger suggested is a third option, although you’d have to do that for every action (twice for two-noun ones: both UNLOCK and UNLOCK DOOR should be caught).

I’d do what Roger said. Except that rather than “convert to the taking action …”, I’d go with “try taking …”. (Ensures that all taking rules are checked, just as if the player had typed “take cake”.)

That is, this can trigger the “supplying a missing noun” activity:

Understand "take" as taking.
Understand "take [things]" as taking.

In Roger’s example, “take” by itself invokes an action with zero objects, so the “supplying a missing noun” activity will never be triggered.

(This is what Draconis said. I’m just repeating it to be clear.)

I think what I was looking for was understanding a topic.

Understand "take" as "[command]".

After reading a command:
     if the player's command includes "[command]":

This effectively gives you a way to understand “an action” by understanding the topic that leads to that action, before moving on from the reading a command activity. Of course, you have to manage every word that is tied to taking an action, including other understand synonyms, but it does seem to work.

If that works for you, great, but at this point it looks like it would be easier to build your own parser than to effectively prevent the standard one from doing anything. :stuck_out_tongue:

Now I don’t know about that! I’m passing everything through the standard parser in the end, I just need to perform additional logic on commands before passing it through because of the complexity of other parts of my application. I mean, what I’m really not relying on is having unique thing objects, and using kinds. Those are the conventions that are being re-routed, not the parser really. I mean, I actually am using those, but only very very few of them. The standard parser is still really being used, but I am just trying to tightly control it instead of letting it decide what to pick.

I think it’s a little bit of hyperbole to say I’d need to make my own parser because I’m making my own property substitutions. The parser involves the understanding topics, which is far more complex than my workarounds for more tightly controlling what topics it understands. Those aren’t equivalent. I’ve looked at the code that operates the parser, and it is FAR more complex than what I’ve done :slight_smile:

I dunno… I would like to be able to operate “normally” for how people write in this language instead of doing any of this, but as seen in my other topics, that just doesn’t seem possible while retaining scalability of a large application. I’d love it if someone more adept than I would come up with a better way to create a system for Inform that offered a scalable, performance friendly framework for putting thousands of things into the system, and giving easy but tight control over the parser output to the programmer… I just haven’t seen this yet. Some people have made some impressive apps, but they are built on a system that assumes the premise of their intended game, whereas I’m trying to build a framework that could be used to build wildly different games, but operates on the same basic core “sub-engine”.

My comment about circumventing the parser came because you’ve mentioned that you threw out the standard noun parser (because you aren’t using standard objects), and now you’re replacing decent sections of the standard verb parser. There’s nothing wrong with what you’re doing, I just think it might be easier at this point for you to work in something like C++ (which allows complete control over allocating and freeing memory), start from scratch with a verb-noun parser, and add features to it (prepositions, etc) as you need them.

I think this line of reasoning might be underestimating the rest of the Inform and Glulx systems. Really, the only thing I see fundamentally as an issue with it is the inability to reallocate memory. If it could do that, I wouldn’t be bending over backwards, I’d be coding a game by now. Again, though, that’s just one thing to solve for, whereas there’s a lot else going on.

Inform comes with a dedicated compiler, used for building applications intended for text games. It has a library, contents index, skein, and output error messages that are (usually) intuitive and helpfully designed to work with the kind of application expected. It has a large community of people working on fixing, updating, and providing extensions for it. It has this forum, where questions can be asked when one becomes stuck on a problem. Verbs and prepositions are not easy to write, and Inform already has built in understanding of many relationships that are not problematic in and of themselves, but only due to the memory limitation problem. It has interpreters on multiple operating system platforms, not just Windows.

if I strike out on my own, I lose all that, and more that I haven’t mentioned, and am probably not aware of.

Besides, I work on C# and Javascript applications as a web developer all day, so Inform 7 is an intriguing diversion as a hobby due to it’s language syntax attempting to look like human language. Part of the draw is that I’m trying to write in this language for that reason. That may not be the best, most practical reason to write an application in a particular system, but not everything about doing a hobby has to be practical.

Still, I might look into building something in C# or C++ again, as you are correct that I am spending months writing workarounds in Inform 7. I guess I still have hopes that I can eventually finish said workarounds…