Adventure Games and Interactive Fiction

Parsing Questions

by Gamefic on June 7, 2015

Carolyn VanEseltine's post about parser tutorials inspired me to think about what to do when players ask questions in parser games. From her post:

The parser game illusion is one of infinite choice. But in practice, the options available to the player are tightly circumscribed by convention, by the game engine, and by authorial choice.

Furthermore, it isn’t enough for the player to know what to do next. The player also has to phrase it in one of the limited ways that the parser can process.

Valid commands
> examine bucket
> get bucket
> inventory

Invalid commands
> what does the bucket look like
> I want to take the bucket
> what am I supposed to do now

Questions are a frequently ignored issue in parser games. They're not an easy problem to solve. Most parsers are specifically geared to handle imperatives. Other grammatical moods are largely ignored. One of the few exceptions I've found is the implementation of "who am i" in Everybody Dies.

I'm not ready to make a parser that can infer grammatical moods. Fortunately, there's an easier solution. Imperative-centric parsers are perfectly capable of recognizing common interrogative words: who, what, when, where, why and how. In Gamefic, all I have to do is implement actions for them.

The base action simply prompts the player to use a command:

respond :what, do |actor, question|
  actor.tell "It looks like you're asking a question. Try giving a command instead. Use HELP for more information."

From there I added syntaxes for the other interrogative words:

xlate "where :question", "what :question"
xlate "when :question", "what :question"
xlate "why :question", "what :question"
xlate "who :question", "what :question"

There was one other case I decided to implement: "what is" questions. This seemed like a good match for look actions. Easy to implement as a syntax:

xlate "what is :thing", "look :thing"

The questions import is available in the GitHub repo. Suggestions and comments are welcome.