[ Z-Machine] Best approach to enumerating all valid commands

The title says it all: How could I approach the problem of automatically generating all valid/interesting commands for a specific game?

My current approach is reading the The Z-Machine Standards Document http://inform-fiction.org/zmachine/standards/z1point1/index.html and perusing the source code of Frotz, Fweep and Aimfiz while waiting for an epiphany of knowledge.

I am aware that any input produces a valid answer, but by interesting I meant the opposite of:

>uidgahf [That verb is not recognized.]
That is, all valid commands except for the set of commands that trigger uninteresting/boring routines (marked as such).

Any help will be very much appreciated!

Strictly speaking, this is not possible, because the game can parse input commands in arbitrary ways.

You can get a mostly-complete list of verbs by looking through the Z-code dictionary and looking for entries with the verb bit set (bit 0 of the first data byte in the dictionary entry). This lets you generate the first word of the command. (Except for directions and commands like “STEVE, JUMP”.)

Or you can go through the grammar table and pick out complete command templates (like “PUT [NOUN] IN [SECOND]”). This is a better strategy, except that Inform uses a different grammar structure than Infocom Z-machine files.

Then you have to fill in the nouns, which is harder. You can go down the object tree and look at the name properties (lists of dict words), but these are not necessarily complete or sufficient – objects can have custom code to parse their names.

Once you’ve done all that work, you realize that the number of possible commands is exponentially large, even if you take scope into account. (Only referring to objects in the same room – which is not a safe assumption, as some valid commands refer to distant objects.)

1 Like

Best place is the Index within the IDE. If you go to the “actions” tab you’ll get a lot of information about what actions apply in your game.


If you want something to provide for the player in-game, you may need to create a “help” command and include unusual commands you’ve created. You can generate a separate player’s help guide when you “publish” the game that covers basics.

1 Like

First of all, thank you for your quick response.

Now I fully understand the meaning of this fragment…

The Z-machine has some lexical acuity but it doesn’t contain a full parser: it’s like a computer without an operating system. A game program has to contain its own parser and the tables this uses are not part of the formal Z-machine specification.

Some additional questions popped up in my mind… but I feel too stupid now to post them.