Every year, chatbot enthusiasts get together and compete in a simplified Turing test. These contests aren’t at the cutting edge of natural language (NL) technology, but this kind of technology is perfectly suitable for mainstream games — both in terms of simplicity to implement and runtime efficiency.
Nathan asks “I saw the post on the Loebner Competition and it got me thinking. Is there any development to integrate this technology into games such as RPGs for NPCs (Non-Player Characters) and what problems could there be?”
Many games already integrate chatbot-like technology, but it has its limitations and there hasn’t been much visible progress in chatbots since Alice and AIML. Academic research in NL generally (outside of such politically-loaded contests) is proving to be much more fruitful, but this technology requires more dedication from game developers, and as such, remains only an option for independent games.
Generally speaking, there are two aspects of chatbots and NL research, both of which are applicable to different types of games:
Understanding — Requires parsing text, and extracting meaning from it.
Generating Language — Focuses on generating dialog from current knowledge.
I’ll give you a quick overview of two ways to approach these problems: the simple chatbot way, and the more “academic” NL way.
One of the simplest ways to get started with chat-bot technology is to use pattern matching to figure out an appropriate response, as made popular by AIML, the markup language that Alice uses.
- The idea is to write a huge database of patterns in one big XML file. Each pattern contains specific words and wildcards, so different variations of the same text are recognized. Then the response associated with the pattern is output.
- To integrate this kind of technology, you need a pattern recognition engine: something like regular expressions or a variation of AIML. Then it’s just a matter of connecting this engine to the console where the player inputs text — like in Quake 3.
- The problem is that pattern matching is really just a reactive AI, and at best, it can only respond accurately to your last statement. It’s the reason why chat bots aren’t very logical! This limits the applicability of the technology to specific parts of games that don’t feature much interaction.
Effectively, this approach is limited to the classic bots in multiplayer shooters. It’s not meant for meaningful conversations, but it does the trick of keeping the player stimulated! So it’d only be appropriate for RPG characters that don’t have much to say.
Natural Language Understanding
You can take pattern matching technology to the next level by going beyond reactive AI.
- The idea is to use the patterns to update a logical model of the conversation, and use that to create dialog. So you still use patterns like in AIML, but these are connected to logical rules which update facts. It’ll take a bit more knowledge of first-order logic to pull this off.
- This kind of technology has been integrated into Façade. The major difference here is that the developers don’t write simple text patterns, they implement logical rules and behaviors that deal with the text written.
- It’s an open field of research, and a different set of skills is required. Don’t expect to be able to deal with open-ended conversations yet though; like for AIML patterns, it’s still important to edit the correct rules for the kinds of situations encountered in your game.
This approach seems like the best known NL understanding technology to have been integrated into games. Anything beyond remains experimental… However, there’s a huge potential here for creating more intelligent RPG characters.
Now, moving on to very simple NL generation. The patterns for matching text is only one half of AIML; the other half contains templates that specify how to output text.
- Instead of making each response out of English words only, you can use a template sentence which includes logic to fill in words dynamically based on the context. This works very much like printf in traditional programming languages, where you can specify variables to expand like: “You are in %location%, at %health% health.“
- You need to be able to parse and process templates with string substitutions, but that’s about it. This works very well in team FPS games for the bots to communicate vital information to the player like in Unreal Tournament. The advantage of templates is that they also work for piecing together segments of voice recording, so it’s not limited to text output.
- Ultimately, the templates are still very limited and don’t contain any more variation than what’s in the database. It’s a very author-intensive approach.
Many games in practice use such templates, whether they are text based or simply combine audio fragments together to generate voices. RPGs with typical dialog trees could benefit from such templates. They are simple to implement and efficient, but they certainly have their limitations…
Natural Language Generation
Many academic and commercial projects have successfully managed to beyond patterns for NL generation. This research topic is better understood.
- The key insight is to use a better model of the English language. This would typically be a hand-edited graph that explains how sentences are built from components, and the same recursively. Then at runtime, you’d traverse this data-structure to generate sentences according to the current goal of the AI. (See the NLP Group at Columbia University for a starting point.)
- In terms of integrating this technology into games, Interactive Fiction is the best place to look for inspiration. Many of the independent games in the recent IF 2007 competition are built from detailed NL models of the storyworld, and the logic necessary to output the correct text according to the player’s actions.
- There’s existing technology to help you build IF games (e.g. Z-Code), but going beyond that and doing better NL generation requires a fair bit of experience with classical AI techniques. Also note that this technology would be very hard to hook up to a traditional audio system with recorded voices.
That covers the variety of different chatbot and natural language technology that’s applicable to games, and the different problems you can encounter while integrating it. Keep in mind that this kind of technology is still author-intensive, so you’ll need to allocate a lot of time to model your NL domain and/or storyworld. On the bright side, there are lots of opportunities to design innovative games using these ideas!