游戏邦在:
杂志专栏:
gamerboom.com订阅到鲜果订阅到抓虾google reader订阅到有道订阅到QQ邮箱订阅到帮看

分享为游戏创造出色NPC的可用软件和方法

发布时间:2013-03-19 17:01:59 Tags:,,,,

作者:Paul Tero

是否还有玩家记得《塞尔达传说2: 林克的冒险》?这是面向第一代NES的一款出色的奇幻游戏,并且在当时(1989年)我几乎天天晚上都沉浸于这款游戏中。游戏中的非玩家角色非常简单,例如一个村民将提示玩家前往下一个地牢的方向。而在最新的《塞尔达传说:天空之剑》(2011年)中,我们发现任天堂的NPC也并未做出较大的改进,即便在过去这20几年时间里计算机和游戏开发都得到了较大的发展。

Zelda(from gamasutra)

Zelda(from gamasutra)

上图是从1987年到2011年的任天堂《塞尔达传说》系列,我们可以从图像上看到巨大的飞跃,但是对话中却并非如此。

如今有许多计算机和在线游戏的NPC都比《塞尔达传说》来得优秀,后者的NPC是遵循着更加复杂的分支对话树。而玩家经常需要基于多种选择(就像《天空之剑》那样)或关键词识别去穿越这棵对话树。这里还存在许多改善空间,特别是让玩家能够打出任何自己想要的内容,并在对话中与NPC进行交流,而不是无止尽地接收有限的预制陈述内容。根据几个月前Gamasutra上所刊登的一篇文章,与NPC交流是未来游戏开发需要重视的一大领域之一。

可用软件

我们可以使用各种不同的方法去创造NPC并将其整合到游戏中。我们可以使用各种视觉对话引擎,如Chat Mapper能让玩家描绘出自己的NPC并规划分支对话。同时也有一种更加特别的方法,即使用定做的XML文件去计划对话,从而确保它能有效地整合到其余的游戏内容中。交互式小说是另外一个相关领域。即存在特别专注于引擎对话的chatbot。他们将推动自由文本输入并创造出各种输出内容。而本篇文章将着重讨论NPC的对话部分,所以将只陈述chatbots的相关内容。

creating-npcs-chatmapper(from gamasutra)

creating-npcs-chatmapper(from gamasutra)

技能组合

使用这些方法所需要的技能取决于开发者和作者。这是一个有趣且具有创造性的过程。但是也有可能需要花些时间。开发者可能会觉得写作元素过于沉闷,而作者可能会受不了其中的逻辑性。所以如果是一整个团队的人共同使用的话,这也许就是一种很棒的方法。

该搜索什么

创造NPC的第一个难点便是明确需要在谷歌中寻找什么。你可以尝试着搜索“NPC创造者”或一些类似的内容。但有可能因此搜出一些用于生成角色扮演游戏的随机NPC(如生命值和武器类型之类的)的网站。

相反地,尝试着去搜索“chatbot创造者”。“chatbot”这一术语的的范围有别于“NPC”。一方面,它包含着网页和智能手机的虚拟助手——不管是宜家的Anna还是苹果的Siri;另一方面是关于图灵测试的更加学术性的挑战,以此检测人工智能是否能够模仿人类。但是因为现在的游戏似乎缺少了NPC聊天功能,所以chatbot便是我们完善NPC的好方法。搜索“bot”的话我们也许还能找到“chatbots”,但是如果搜索的是“bot创造者”,我们得到的结果便有可能是3D打印机或网络爬虫。

chatbot软件

在本篇文章的最后我们需要选择我所遇到过的chatbot制造商,其中将包括我曾帮助开发的对象。他们都是基于某种类型的文件创造(如文本,XML或电子数据表),然后使用软件进行加工并将其转变成能够用于聊天的bot。这种方法总是直接整合玩家的输入(如“哪条路是通向地牢”?)与chatbot的输出(“左边的第二个洞穴”)。问题就在于,关于“哪条路是通向地牢”存在着上百万种独特的询问方式,而“左边的第二个洞穴”也有上百种回答方式。开发者/作者的目标是在合理的时间内尽可能覆盖所有的这些内容。而最简单的方法便是在用户输入中寻找关键词“地牢”,然后始终给出相同的回应。但这与现在游戏的NPC做法非常相似,并且可以不使用任何第三方软件而进行编写。

挑战

因此一大挑战便是创造出可以无需输入内容便能识别上千,甚至是数百万输入内容的chatbot,并呈现出各种输出变量。

另外一个挑战便是如何处理分支脚本,即一个问题引出其它问题。以下没有一个chatbot拥有像上述对话引擎那样的视觉数据输入格式,一是因为这会限制它们的灵活性,其次是因为他们需要花较长时间进行编程。所以他们选择能够设置并获得变量的系统,并基于这些变量而提供各种不同的输出内容。

Cleverscript

Cleverscript是由大受欢迎的Cleverbot的创造公司所创造的。它使用的是电子数据表格式,并且拥有非常强大的工具能够阻止按并维护变量。我们可以在Cleverscript网站上加载电子数据表,并将其转变成能够进行测试的bot。电子数据表中的格式如下:

input hello hello / hi / hi there
output      hello      Hello!

creating-npcs-skyfall(from gamasutra)

creating-npcs-skyfall(from gamasutra)

为了能在自己的网站或应用上使用bot,你必须花钱访问网络服务,或请求程序库包含智能手机项目。Cleverscript的一大优势便是包含了一个迷你Cleverbot引擎,也就意味着你无需编写所有对话。

AIML

AIML代表人工智能标记语言。这是用于创造chatbot的XML格式。该格式如下:

WHAT IS YOUR NAME
My name is John.

最有名的AIML chatbot是ALICE,即人工语言网络计算机实体。当你创造了自己的AIML bot后,你便能够将ALICE的AIML以及其它AIML用户所贡献的程序库(包含各种欧洲语言)整合进去。在创造了XML文件后你需要采用某些方法去运行它。最简单的方法便是Pandora Bots所提供的免费网络服务。也存在各种解释器能够用于不同程序语言中,包括C++和Java,让你能够独自运行。

ChatScript

ChatScript是一款免费的开源C++程序库。你可以面向任何平台进行编译。游戏开发商Outfit 7便是使用ChatScript去完善他们大受欢迎的《Tom Loves Angela app》(游戏邦注:面向谷歌的Android和iOS平台)。开发者是使用包含了预期用户输入和相关bot输出内容列表的文本文件去创造bot。就像是:

u: (what are you) ^keep() ^repeat() I am a bot.

其格式包含了再次使用文本并记住用户喜好的方法。你可以将文件编译到自己的游戏中,并在智能手机或网络服务器上直接运行。

建议

因为我参与了Cleverscript的开发,所以我会更倾向于于这一软件。我认为它比其它软件更灵活且更加强大,包含了高级的变量系统和直观的组织语言。它并不需要使用什么数据输入,并能够有效地处理分支脚本,尽管视觉数据输入格式将对此进行处理。而在所有免费软件中我则支持更紧凑的ChatScript格式,尽管它也更具有技巧性。我个人更希望解释器是由想出输入格式的那个人进行编写。这就意味着格式的改变与添加是与软件本身紧密联系在一起的。

本文为游戏邦/gamerboom.com编译,拒绝任何不保留版权的转载,如需转载请联系:游戏邦

Creating Better NPCs

by Paul Tero

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.

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

There 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.

Challenges

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.

Cleverscript

Cleverscript 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

AIML stands for Articifial Intelligence Markup Language. It is an XML format used for creating a chatbot. The format looks like this:

WHAT IS YOUR NAME
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.

ChatScript

ChatScript 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.

Recommendation

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.(source:gamasutra)


上一篇:

下一篇: