Progress of the Parser

I find this fascinating! Love working through stuff like this.

You ultimately go round in full circles because eventually you end up saying “let’s just fix the fixable problem” and summise that a simple 2-4 word system is best; going any further than that is to wind up leaving the text adventure reservation and heading off into AI country!

Adam

1 Like

To @zarf’s point, the above represents a challenge that you can well imagine McCarthy and Minsky tackling back in the heady days of 1960s AI!

Adam

1 Like

I’ve also wished before that Inform would use a more modern parsing algorithm, which would let it deal with “fake ambiguity”: if the player is carrying a “letter to Ethan”, and tries to “GIVE LETTER TO ETHAN”, the only sensible parse is “give (letter) to (Ethan)”. But Inform will instead come up with the parse “give (letter to Ethan)”, see that there aren’t enough words left to match “give [NP] to [NP]”, and complain.

1 Like

Don’t forget the “pick the ___ statute up” phrasing.

The feature you want here is to maintain a list of possible parses, explore all possibilities, and then pick the best. (In this case, a complete grammar-line match would score higher than a partial match.)

Inform does this in a limited way – when disambiguating noun phrases. It can’t do it for the complete grammar line. This is a straight-up example of “it wasn’t practical on the Z-machine and it never got added.” (In a modern language, with hash tables and arrays trivially available, it’s a lot easier.)

2 Likes

Oof. You might want to fix that quote. That was @zarf correcting me (thanks!): Inform does and apparently always has done duplicates. The manual says “there are four caveats” (and it’s not a feature that I’ve seen used much) so I was probably misremembering from that, but they all are perfectly sensible caveats and don’t look like they’d get in your way much.

1 Like

The ISHML parser is designed to do this.

IMO, the potential for fancy AI/ML parsers isn’t so much to actually support a broader range of typed commands, but to generate better error messages and hints, guiding players to type what they’re “supposed” to type instead of trying to translate arbitrary input into valid game commands.

7 Likes

Agreed. Smarter Parser by Aaron Reed has has problems in its current incarnation, but it’s got the right idea: take every command that was rejected by the standard parser, analyse it and try to work out what is wrong with it, and then print a suitable helpful message (and if possible extract a valid game command to send back to the parser.) Throw Google Natural Language API or similar in there and write ten times the number of help messages to cover every common kind of mistake, and we might be getting somewhere.

2 Likes

I don’t know what’s so impractical about it. Dialog does exactly that, for full phrases, on the Z-machine.

Of course: “If I have hacked deeper than them, it is because I stand in their trenches.” (Graham Nelson)

Two cute examples from the Dialog manual: “READ TO KILL A MOCKINGBIRD TO MOCKINGBIRD” and “GIVE ATTILA THE HUN A COOKIE”.

5 Likes

It’s sad to me that Smarter Parser didn’t kick off a movement, that it didn’t become part of the standard toolbox for Inform games.

But, in hindsight, I don’t see how it could have. New authors probably aren’t going to know about Smarter Parser, and aren’t going to reach for it even if they do know about it, and experienced IF players have no need to demand it. Worse, if you’re the sort of author who likes customizing all of the standard error messages, Smarter Parser just makes your life harder.

I think it would have required Inform to make Smarter Parser somehow part of the standard default for new Inform games, but a big messy complicated extension like that isn’t a natural fit for the standard library.

As a result, it’s hard to see a path toward big improvements in Inform’s default error messages, which, I claim, are a significant source of friction for newbies. :slightly_frowning_face:

2 Likes

I like this. Good approach.

Adam

I don’t want to pick on Smarter Parser here, because I think it is very useful, but its fundamental problem is that it makes heavy use of the slow regular expression implementation of Inform 7. Also, when it kicks in, the Inform parser has already spent a lot of time trying to make sense of the player’s command, which makes the total pause more noticeable.

It also uses keyword matching rather than syntactic analysis, and if it didn’t it would be even slower. TAEK THE SCREW and SCREW THIS! are both understood as the player swearing in frustration, because they include the word SCREW.

What we would need is something that is super fast, accurate and included in every new game by default, and at the same time is easy for the player to switch off.

2 Likes

We can build this in ZIL :slightly_smiling_face::+1: It’s totally possible, just time consuming to do.

1 Like

Now, I must admit, I don’t mind a pause and in fact I would go as far as saying I prefer it even! A pause between the player hitting Enter and the computer displaying an output makes me feel as though the computer has really thought about it, it feels more real to me. But I realise this is personal preference.

Adam

1 Like

Nearly gave me a stroke coding it, but just for fun… :smiley:

Adam

4 Likes

Does plant the plant in the pot work?

1 Like

It does indeed!

Happy to share the source code if anyone is interested.

Adam

1 Like

I’d be curious…