Mailbag: Knowledge-driven Dialogue in Inform

I am doing my first steps in Interactive Fiction and your work has helped me a lot. I have been working on an idea, that requires dialogue based on “knowledge”, in other words, the character and the NPCs will initiate dialogue in order to fill out their gaps in knowing the other person. Firstly, I was wondering if Inform7 can do something like that, and if it can which dialogue system would be the best to serve as a basis. Secondly, I was wondering if Inform7 can implement AI, without falling back to Inform6. Thank you in advance and most importantly, for your work in the community! Sorry for the annoyance of my question but I was kind of lost among the many different dialogue systems that are out there…
[and then on confirmation that the asker was okay with a mailbag post]:

First of all let me clarify that I am not asking for mentorship, with this question. More like pointing to the right direction, if there is such a direction. There is a strong chance that there is not something similar implemented, so in this case, don’t let me take your time.

My question is if there is a dialogue system in Inform7 (or in some other framework) , that is based on knowledge of a predefined set of data. For instance the protagonist to be able to query for any one of that data and to store that information in such a way, that the next answer to reveal even more data. Or the knowledge itself to enable the protagonist to make more specific questions. The answer I would like, is not how to implement such a system, of course, but only a reference of the type  “have a look at this extension of Inform7” or “there is no such thing implemented” or “there is no such thing, but you could draw inspiration from this”. Nothing more than that! I have thought of a potential implementation, treating data as things that are visible or not, and the knowledge to be treated as “possession” of those things, but I am not certain it is the right approach.

First of all, re. the Inform 6/7 question: Inform 7 is a full programming language, and you do not need to drop to Inform 6 to code behavior. In the early years there were things that were hard to express in Inform 7, especially mathematical things or elements that accessed files or manipulated on-screen behavior, but most of those elements do now have an Inform 7 wrapper available. Occasionally people still choose to insert Inform 6 chunks inside an Inform 7 program for various reasons, but it isn’t required.

Likewise, when you say “to implement AI,” this is such a big and fuzzy question that it’s hard to answer without more of a breakdown.

Inform 7 is good — and indeed much better than Inform 6 — for handling rule-based decision-making and firing off character interactions within the model world; the main issue here is performance if you’re driving a large number of characters or asking them to plan over complex world state. The rule-based aspects of Inform 7 in fact have influenced other approaches to game AI in larger game applications, as Elan Ruskin discusses in one of his GDC talks.

For other AI approaches, you’d have to do quite a bit more work; for instance, it isn’t really designed to make use of any natural language processing methods outside of its own rich and complex parsing mechanism, and if you wanted to do something that for instance tried to guess what the player meant by words that weren’t in the game’s dictionary but might be similar to ones that were, you’d more likely use some kind of special pre-processing layer or a call out to an external script, because it doesn’t provide ways to e.g. access WordNet or a word2vec model. Likewise, it’s not designed to plug together with SpaCy or Google NLU or any of the external tools that have come into being over the past decade+ to help interpret the semantic structure of a piece of input. It might be interesting to explore how that would work, but that doesn’t exist currently.

Inform plus machine learning is a slightly more interesting point of conversation, because the TextWorld project exists, and there are researchers who are exploring how to use an Inform-based world model as a sandbox environment for training ML agents to solve a text-based game.

That’s different again from the idea of an ML agent designed not to solve an IF game but to be a companion or competitor within an IF game, for the sake of enhancing the player’s experience. There are relatively few IF games in which it would even really be meaningful to talk about a competitor character within a game, because most IF doesn’t have mechanics designed for competitive play (though Kerkerkruip might work). My old game When in Rome 2 also featured an NPC with dynamically selected characteristics who might work counter to the intentions of the player, and it was possible in some cases to be bested or even killed by this creature, if you went up against a clever one and it got resources ready faster than you could.

Now, on to the main question.

Most of the approaches I know of in Inform handle knowledge progression as a (nonphysical) kind of unlocking. They are tracking what the player knows so far in order to determine what next information could be made available, but this doesn’t provide an abstraction level beyond the individual dialogue lines themselves.

Eric Eve’s Epistemology is designed to track what the player knows, which can unlock topics of conversation; this can be used with the rest of Eric’s conversation extensions as well, if appropriate. This handles the case that the player has learned about a new topic in conversation; it also allows for the possibility that the player sees things in the surrounding world and is reacting to those.

The Threaded Conversation extension I wrote (but that is now maintained by others) has a general-purpose concept of prerequisites on conversation, and this can be used to track factual knowledge known as well as specific previous dialogue utterances.

This approach is not the same as having a complex database of knowledge or of the relationships between knowledge, so that the system might automatically have characters progress from discussing say candy to discussing related topics (cake, halloween). My game Glass explores that concept a bit by implementing a network of related conversation topics and ways to pathfind and transition between these.

The older (and not particularly well-received, I have to admit) game Best of Three has a character who is implemented to have a tree of inferences he can make, and he’ll ask questions in order to try to unlock facts lower in the tree so that he can prove the inferences higher up in the system. The aim here was to create a character who seemed to intentionally pursue topics that the player might not want to reveal.

Another way of organizing information for conversational knowledge-seeking is with the concept of frames — the idea being that in order to achieve various conversational goals, the contents of the frame need to be filled out. This is useful for transactional interactions like travel booking, where you need the booking agent to keep dynamically asking questions about the flight you want booked until they’ve established dates and times of both outbound and return trips, the departure and arrival cities, class of travel, etc. I don’t know of any Inform extensions that explicitly attempt to handle the frames concept, though it’s possible someone’s built something somewhere. (For more about AI knowledge representation in general, Knowledge Representation and Reasoning is a few years old and fairly chewy but outlines a number of different approaches.)

Finally, part of what we’re doing on Spirit AI’s Character Engine (which, admittedly, is well outside the Inform ecosystem) is to focus much more on dialogue and knowledge, with more primary support for databases of knowledge, characters who know which pieces of knowledge have been mentioned in recent interactions, and the ability for characters to pursue particular interaction goals, or interpret “tell me more about X” sorts of inquiries. So that’s an alternative space where I’m working with some of this.

Leave a comment