Gamasutra: The Art & Business of Making Gamesspacer
View All     RSS
September 23, 2014
arrowPress Releases
September 23, 2014
PR Newswire
View All

If you enjoy reading this site, you might also want to check out these UBM Tech sites:

Creating Better NPCs
by Paul Tero on 03/18/13 07:06:00 am   Featured Blogs

The following blog post, unless otherwise noted, was written by a member of Gamasutra’s community.
The thoughts and opinions expressed are those of the writer and not Gamasutra or its parent company.

Do many gamers remember Zelda II: Adventure of Link? It was an excellent fantasy game for the first Nintendo Entertainment System which occupied quite a lot of my evenings in 1989. The Non Player Characters were very basic though - typically a lone villager who hints which direction to head for the next dungeon. The villager kept on repeating the same hint long after I'd moved on. Nintendo's NPCs are not much better in the latest Zelda instalment Skyward Sword in 2011, despite over 20 years of computer and game development in between.

Adventure of Link screenshot Skyward Sword screenshot
Nintendo's Zelda series from 1987 to 2011, a huge leap in graphics but not dialogue. 

There are now many computer and online games where NPCs are better than this, where the NPCs do follow more complex branching dialogue trees. However the player's path through the tree is often by multiple-choice (as in Skyward Sword above) or keyword recognition. There's a lot of room for improvement, particularly in allowing the player to type whatever they want and engage in a conversation with an NPC, rather than repeatedly receiving the same limited set of preset statements. NPC chatting was one of the key areas of future game development identified during a conference review posted on Gamasutra a few months ago.

Software available
Chat Mapper screeshotThere are a few different approaches to making NPCs to include in games. There are visual dialogue engines like Chat Mapper (screenshot on right) which allow you to describe your NPCs and map out branching dialogues. There is a more ad-hoc approach, using bespoke XML files to plan dialogue so it integrates well with the rest of the game. Interactive fiction is another related field. And there are chatbots - which specifically focus on engaging dialogue. They encourage free text input and can produce a variety of output. This blog post is about the conversational side of NPCs and so only discusses chatbots.
Skill set
The required skill set to use any of these approaches is somewhere between a developer and a writer. It can be a very fun and creative process. However it can also take a long time. Developers may find the writing aspect tedious and writers may find it the logic of it overwhelming. It is maybe better approached by a team of people working together.

What to look for
The first difficulty in creating NPCs is knowing what to look for in Google. You might try searching for "npc creators" or something similar. But that tends to bring up websites for generating random NPCs for role playing games like Dungeon & Dragons (hit points, weapon types, things like that).

Instead try searching for "chatbot creator". The term "chatbot" has different scope from "NPC". At one end, it covers virtual assistants for websites and smartphones - from IKEA's Anna to Apple's Siri. At the other is the more academic challenge of the Turing Test to see whether an artificial intelligence is capable of imitating a human. But since it is the chatting ability of NPCs that seems most lacking in current games, chatbots are a good place to start when thinking about how to spice up NPCs. The term "bot" is also used for "chatbots" but if you search for "bot makers" you get everything from 3D printers to web crawlers.
Chatbot software
At the end of this article is a selection of chatbot makers that I have come across, including one that I have helped to develop. They all rely on the creation of a file of some sort (text, XML or spreadsheet) which is then processed by the software and turned into a bot which you can chat too. The format used usually directly associates a player's input (such as "which way to the dungeon?") with the chatbot's output ("second cave on the right").
The problem is that there may be millions of unique ways of asking "which path should I take to the next dungeon?" and hundreds of ways of answering "enter the second cavern on your right". The goal of the developer/writer is cover as many of these as possible in a reasonable amount of time. The easiest approach is to look for the keyword "dungeon" in the user input and then always give the same reply. But that's pretty much what NPCs do now and could be programmed quite simply without any third party software.

One of the main challenges therefore is to build a chatbot which can recognise thousands or millions of inputs without you having to type them all, and which can give many variations of output. That's what the software below provides, with varying degrees of success.

Another challenge is how they handle branching scripts - where one question leads to another. None of the chatbots below have a visual data entry format like the dialogue engine above - partly because it would limit their flexibility, and partly because it would take a long time to program. Instead they have systems for setting and getting variables and giving different outputs depending on them.
Skyfall game created using CleverscriptCleverscript is made by the company behind the very popular Cleverbot. It uses a spreadsheet format and has powerful tools for organising language and maintaining variables. Spreadsheets are uploaded at the Cleverscript website and turned into bots which you can test. The lines of the spreadsheet look roughly like this:
input hello hello / hi / hi there
output      hello      Hello!

To use the bots in your own website or app, you have to pay for access to a web service, or to request libraries for inclusion in smartphone projects. One of the big advantages of Cleverscript is that it includes a mini-Cleverbot engine, which means you don't have to script all conversation. It will be able to small-talk out of the box. On the right is a screenshot from a game which used Cleverscript and promoted the film Skyfall.
AIML stands for Articifial Intelligence Markup Language. It is an XML format used for creating a chatbot. The format looks like this:
  My name is John.

The most famous AIML chatbot is ALICE, the Artificial Linguistic Internet Computer Entity. When you create your own AIML bot, you can include ALICE's AIML as well as libraries contributed by other AIML users, including in several European languages. This reduces the data entry burden. Having created your XML file, you need some means of running it. The easiest method appears to be as a free web service provided by Pandora Bots. There are also several interpreters available in different programming languages including C++ and Java so you can run it yourself.
Tom Loves Angela screenshotChatScript is a free open-source C++ library. You can compile it for whatever platform you need. Outfit 7 used ChatScript to power their popular Tom Loves Angela app (screenshot on right) for Google Android and iOS. Bots are created using a text file which contains lists of expected user inputs and corresponding bot outputs. They look like this:
u: (what are you) ^keep() ^repeat() I am a bot.

The format includes methods for reusing text and remembering user preferences. The text file is run though the software to produce a bot you can chat to. The software can be compiled into your own game and run directly on a smartphone or your web server.

I am biased because I helped to develop Cleverscript. I think it is more flexible and powerful than the others, including an advanced variable system and an intuitive way of organising language. There is less data entry needed, and it handles branching scripts fairly well, though a visual data entry format would enhance it. Among the free ones, I favour the more compact format of ChatScript, even if it is more technical. I personally also prefer that the interpreter is written by the same person/people who came up with the input format. It means that changes and additions to the format develop alongside the software itself.
There may also be other software packages and approaches out there too, but I've focused only on popular chatbot creators. And to be fair to Nintendo - allowing free text input on a joystick would have been very tedious. They are still great games.

Related Jobs

Amazon — Irvine, California, United States

Software Development Manager
Avalanche Studios
Avalanche Studios — New York, New York, United States

Technical Artist
Phosphor Games Studio
Phosphor Games Studio — Chicago, Illinois, United States

Jr. Programmer – Unity
Phosphor Games Studio
Phosphor Games Studio — Chicago, Illinois, United States

Jr. Programmer – Unity


Mathieu MarquisBolduc
profile image
Put it in a playtest, and you will find most players just want to skip that stuff to get to the relevant information as fast as possible. Especially in an adventure game, most people dont really play to chat with the locals.

evan c
profile image
Exactly. Players usually talk to npc's to see if they'll mention anything interesting. Unless you're making a Sims like game where you can build a relationship with the npc a robust conversation could be too distracting or just a waste of time.

The most interesting npc conversation I found in a game is from SNES Shadowrun. The game allows you to ask a specific topic to an npc and if you ask the right question it can give you a hint on what to do next or they give you new information to ask other npc's. I wish someone would do this again.

Rene Rebane
profile image
Isn't that a question of game design and how the whole gameplay is built up? All the games are not the same. I would really like to see something like this and that gameplay would support this feature.

E Zachary Knight
profile image

Those NPCs in Shadowrun were early chat bots. Chatbots are big databases of responses and questions that look for specific keywords and then find an appropriate response. That is what those NPCs were doing.

While I don't think games need to full on Turing with its NPCs, I would think having NPCs that respond to more than a canned dialog tree would be entertaining in the right game.

Michael DeFazio
profile image
Just a thought, but what I think would be a great addition to a facility like cleverscript would be to have separate "corpuses of knowledge" and NPCs can be defined by groups/affiliations... for example:

bartertown locals (group) all know basic information about bartertown, so making small talk to any of them and they'll give you similar responses for base information/keywords (weapons, hotel, food ...)

bartertown guards (group) know rumors about a plot to kill a local noble

bartertown guard lieutenants (group) know that Sixtus (a powerful and influential gem merchant), is trying to hire an assassin to kill Claudius the local magistrate.

Triel a bartertown guard first lieutenant (part of all of the groups above) is in financial ruin due to a borrowing money from the local thieves guild.

To gain access to the pertinent information (about Sixtus/Claudius) the player might:
a) Bribe Triel to have him give you the information
b) Talk to the Thieves guild (on Triel's behalf) to get them to wipe away the debt (perhpas by doing a job for them)
c) Threaten Triel that you'll go public with his dealings with the thieves guild if he doesn't tell you more about the plot


find any other Lieutenant and figure out how to persuade them to find out more about the plot. (Perhaps there is one shady guard who'll tell you if you give him money, or another who writes everything down in a log book, and you can sneak into his house and find out the information, or you can sneak in and eaves drop on the captain and his lieutenants to hear them discussing the plot...)

the key is that what NPCs KNOW (and freely talk about) should be DIFFERENT from what they SAY... so you can have many routes to finding out the same information (through intimidation, bribery, eaves dropping etc.)

As for the comments above... I hear what you are saying, (about players skipping content) however if the player finds out that many of the best/most interesting content is available only to those who spend time with the dialog, then they may look at dialog differently (I think people at this point are so used to fixed/skippable dialog that it would be an adjustment, but I definitely see the point in trying something new given how stale things have gotten in the character interaction department).

Paul Tero
profile image
I agree - it's a great idea. To give NPCs some core data along with information that only they know, some of which they guard closely. I think fantasy and adventure games would be enhanced a lot if you had to convince an NPC through conversation to give you information. Game designers could add lots of new sub-games and puzzles. And with the write scripting engine (chatbot), it would probably take less time than adding new graphical/visual puzzles. I agree about players skipping dialogue now. I think they'd quickly appreciate the new challenges.

Brian Handy
profile image
Cool article! And bravo on Cleverbot, very convincing stuff.

I'm curious to know if you think there's room for bots that can learn English, rather than just pre-programmed dialogue responses and variants of that. So, something where the bot learns English, then you give it some information and a speech style, and it conveys it however it wants.

Paul Tero
profile image
Thanks! That's pretty much what Cleverbot does. It's mostly a website which has been learning English (and many other languages) for years from users. Whenever you talk to it, it replies back with something that someone else said to it in the past. With Cleverscript, we've combined the pre-programmed responses with underlying Cleverbot data. So if an NPC recognises a specific question "where's the key?" it will give a pre-programmed (scripted) reply, or else it will just chat with English it's learned in the past. We could give different bots different personalities or styles too - we're working on that at the moment actually.

Brian Devins
profile image
I like how Everquest handled NPC conversation. It gave the player a static blurb of text with various keywords in brackets, and the player could write a chat message using these keywords to prompt further conversation.

For example, the NPC might say "There is a [reward] for whoever helps me!" to which the player could type "Tell me about your reward, cowardly shrew!"

This is an inexpensive way of enriching player\NPC interactions that pushes the onus of creativity onto the player. It's a creative way of allowing the player to engage at whatever level they wish.

On the other hand, why not design an MMO that rewards players for giving quests to other players?

Chatbots are a wonderful idea but very labour-intensive, as any text parser adventure game designer will attest.

Paul Laroquod
profile image
Chatbots are a bad idea for any game where you wish to maintain suspension of disbelief, which is probably all the games, because the important thing to remember about the Turing Test is that no computer has ever passed it -- in fact, most fail within a few turns. Therefore, using a chatbot to represent a human in a narrative game is about as smart an artistic choice as using a giant three-storey marshmallow to represent a pacer car in a racing game.