Intelligent NPC's

19 views
Skip to first unread message

Gary Leighton

unread,
Nov 18, 2003, 4:09:28 PM11/18/03
to
I'm interested in writing IF that has "intelligent" NPC's. I'd like them to
perform the same kind of actions as the main player character, to accept
goals, and to plan sequences of actions during the game to satisfy the
goals.

Are there any good games that already do this kind of thing?

Is there any support in the designer programs for doing this? Third party
libraries maybe for TADS or Inform?

Do you think this would add an interesting new dimension to IF or is this
kind of thing disliked?

Gary Leighton


Quintin Stone

unread,
Nov 18, 2003, 4:31:43 PM11/18/03
to

I think intelligent NPCs are always welcomed. The trick, however, is
writing them. The topic has come up before, certainly. I think the last
thread addressed the idea of giving each NPC several internal "sliders"
that measured their current mood based on a number of different
emotional/mental/physical states. The reason intelligent NPCs are rare is
because coding them is a very difficult task, and creating a generic
plug-in system (like you're looking for) adds complexity at the level of
probably another order of magnitude. I have an idea for my next game that
does involves an intelligent NPC; I haven't even begun to work on code
yet, however.

/====================================================================\
|| Quintin Stone O- > "You speak of necessary evil? One ||
|| Code Monkey < of those necessities is that if ||
|| Rebel Programmers Society > innocents must suffer, the guilty must ||
|| st...@rps.net < suffer more." -- Mackenzie Calhoun ||
|| http://www.rps.net/ > "Once Burned" by Peter David ||
\====================================================================/

The Despoiler

unread,
Nov 18, 2003, 6:36:05 PM11/18/03
to
I was shocked and illuminated when Gary Leighton wrote:

>I'm interested in writing IF that has "intelligent" NPC's. I'd like them to
>perform the same kind of actions as the main player character, to accept
>goals, and to plan sequences of actions during the game to satisfy the
>goals.
>
>Are there any good games that already do this kind of thing?

I've been building single user scenarios where you are given the
choice between up to 9 different characters with varying goals and
motives and are scored according to your chosen character's
accomplishments by the end of a fixed scenario duration.

So far, not many takers....

______
The Despoiler

Gary Leighton

unread,
Nov 19, 2003, 5:27:04 AM11/19/03
to
> I think intelligent NPCs are always welcomed. The trick, however, is
> writing them. The topic has come up before, certainly. I think the last
> thread addressed the idea of giving each NPC several internal "sliders"
> that measured their current mood based on a number of different
> emotional/mental/physical states.

I've been pondering the idea of NPC moods as well, but I'm less comfortable
with this idea. I was thinking that the NPC's could choose an action that
fits with its current mood, and that this might be more, ahem, realistic.
But I think this is getting into Sims territory, and makes it harder for the
designer to control the plot.

On the other hand, if the NPC's are designed to simply find actions that
satisfy designer created goals, the designer then maintains control. The
goals can be designed so that (if satisifed) the plot will adavance. And the
actions necessary to satisfy a goal could be carefully tailored by the
designer to support the story.

I suppose that what I want is a story that results from the dynamic actions
of the NPC's and PC, but I still want to maintain the overall direction of
the story.

So maybe the NPC's could have moods/emotions etc, but only as long as the
resulting actions are plot neutral?


Gary Leighton

unread,
Nov 19, 2003, 5:30:59 AM11/19/03
to
> I've been building single user scenarios where you are given the
> choice between up to 9 different characters with varying goals and
> motives and are scored according to your chosen character's
> accomplishments by the end of a fixed scenario duration.

Interesting, but how are you making your non-player characters intelligent?
Do they act on their own without player input?


ems...@mindspring.com

unread,
Nov 19, 2003, 5:58:43 AM11/19/03
to
"Gary Leighton" <leight...@hotmail.com> wrote in message news:<bpe1q8$gdj$1...@sparta.btinternet.com>...

> I'm interested in writing IF that has "intelligent" NPC's. I'd like them to
> perform the same kind of actions as the main player character, to accept
> goals, and to plan sequences of actions during the game to satisfy the
> goals.
>
> Are there any good games that already do this kind of thing?

> Is there any support in the designer programs for doing this? Third party
> libraries maybe for TADS or Inform?

There are two places I would start looking.

T3 provides a fair amount of support for NPCs being able to interact
with the environment in basically the same way that the player does;
an NPC who tries to take a high object fails (unless programmed not
to) in just the same way, for instance. So that then you can give
NPCs a range of commands which they will be able to carry out in a
well-simulated way, and NPC action scripts become fairly
sophisticated.

To the best of my knowledge, the only game currently available that
takes extensive advantage of this is "Max Blaster and Doris de
Lightning Against the Parrot Creatures of Venus", which you can find
out about at

http://www.wurb.com/if/game/2096

(And excuse the seeming self-promotion, but actually my co-author did
all the NPC-action coding, so I'm really pushing his work, not mine.
:)

The other thing you should look at, whether you're using TADS 2 or
Inform, is Nate Cull's Reactive Agent Planner extension, available for
either language. In fact, even if you choose to work in T3, a little
look at RAP would not be amiss. RAP is non-trivial to learn to use,
but once you've gotten past that, it will let you make goal-seeking
NPCs who develop sophisticated plans and react to changes in their
environment. I was able to put together some surprisingly active and
behaviorally interesting NPCs with it in a fairly short time.

This one you can see in action (again, to the best of my knowledge) in
Peter Berman's odd Speed-IF "Kiss Chase" at

http://www.wurb.com/if/game/1872

Speed-IF, if you're unfamiliar with it, is IF written within two
hours, and as you might expect this is not a highly polished game or
even one whose NPC behavior you would really hold up as an example,
but it does demonstrate the abilities of the NPCs to react to
environmental change and pursue their goals. And RAP allows for
considerable extension beyond what this game show-cases.



> Do you think this would add an interesting new dimension to IF or is this
> kind of thing disliked?

I think it would be interesting; I cannot guarantee whether your
application of the idea would be liked, but in my experience there is
someone who will be impressed by every major piece of experimental IF,
and someone else who will hate it.

The reason you don't see more of this kind of thing already is partly
that it is difficult to program fully (something interesting is easily
made with RAP; something good and fully functional, a bit harder).
And if you want a plot in your game, NPCs who can plan for themselves
may wreak havoc; sometimes it's just easier to order their behavior
according to set rules. You can see some discussion on this topic in
previous years here

http://groups.google.com/groups?dq=&hl=en&lr=&ie=UTF-8&threadm=7d26d66b.0109030448.59339a1a%40posting.google.com

and linked from here

http://bang.dhs.org/if/library/

and some older stuff in the archives as well if you care to search for
it.

-- Emily

Gary Leighton

unread,
Nov 19, 2003, 6:43:10 AM11/19/03
to
Thanks Emily, you've given me plenty to chew on. RAP sounds especially
interesting.

Gary

Daniel Barkalow

unread,
Nov 21, 2003, 2:14:41 PM11/21/03
to
On Tue, 18 Nov 2003, Gary Leighton wrote:

> I'm interested in writing IF that has "intelligent" NPC's. I'd like them to
> perform the same kind of actions as the main player character, to accept
> goals, and to plan sequences of actions during the game to satisfy the
> goals.

You might want to look at Platypus, which is a substantial modification of
the Inform library such that NPCs can use the same sort of actions that
the PC can, with suitable output. This will at least make the world model
amenable to NPCs who do things. Of course, you will still have the issue
of making NPCs do *intelligent* things, but at least the library will
respond sensibly.

-Iabervon
*This .sig unintentionally changed*

Gary Leighton

unread,
Nov 21, 2003, 5:30:28 PM11/21/03
to
I just wanted to give a little bit more feedback than the "err, thanks" of
the other day :)

> T3 provides a fair amount of support for NPCs being able to interact
> with the environment in basically the same way that the player does;
> an NPC who tries to take a high object fails (unless programmed not
> to) in just the same way, for instance. So that then you can give
> NPCs a range of commands which they will be able to carry out in a
> well-simulated way, and NPC action scripts become fairly
> sophisticated.

OK, but I would describe this as minimal support for goal-driven NPC's. But
it does at least make it possible to re-use the existing NPC classes. I'm
suprised that TADS & Inform don't do a bit more to support intelligent NPCs,
out of the box.

> To the best of my knowledge, the only game currently available that
> takes extensive advantage of this is "Max Blaster and Doris de
> Lightning Against the Parrot Creatures of Venus", which you can find
> out about at
>
> http://www.wurb.com/if/game/2096
>

Great, it's on my play-list.

> The other thing you should look at, whether you're using TADS 2 or
> Inform, is Nate Cull's Reactive Agent Planner extension, available for
> either language. In fact, even if you choose to work in T3, a little
> look at RAP would not be amiss. RAP is non-trivial to learn to use,
> but once you've gotten past that, it will let you make goal-seeking
> NPCs who develop sophisticated plans and react to changes in their
> environment. I was able to put together some surprisingly active and
> behaviorally interesting NPCs with it in a fairly short time.

I've had a good read of the docs for RAP, and I'm impressed. I suppose that
a fair amount of work is required from the designer to encode the necessary
plans, but I expect you could do good things with this.

Why isn't everyone using it?

(Actually, the "Looking-Glass Girl" instructions on RAP are a bit like hard
work. Maybe it needs better docs? Entertaining though.)

>
> This one you can see in action (again, to the best of my knowledge) in
> Peter Berman's odd Speed-IF "Kiss Chase" at
>
> http://www.wurb.com/if/game/1872
>

OK, its also my play-list.

> > Do you think this would add an interesting new dimension to IF or is
this
> > kind of thing disliked?
>

> The reason you don't see more of this kind of thing already is partly
> that it is difficult to program fully (something interesting is easily
> made with RAP; something good and fully functional, a bit harder).

agreed. My guess it that the only way this could be 'easy' for the designer
is if the language/NPC classes had built in support. Maybe it needs a
different kind of architecture altogether.

> And if you want a plot in your game, NPCs who can plan for themselves
> may wreak havoc; sometimes it's just easier to order their behavior
> according to set rules.

I would have thought it easy to limit the NPC's available actions and goals
so that they can't do too much damage to the plot. In fact, if I understood
the RAP docs properly, its seems you have to go deliberately out of your way
to give them any kind of powers. That is to say they can only follow the
goals you set, only produce plans according the the sub-plans you define,
and only perform the actions you have assigned to the sub-plans. The
appearance of intelligence only comes from the fact that the
backward-chaining algorithm is capable of produced long strings of goals and
sub-actions by combining your plans.

Actually, this does seem fairly hard work now I think about it.

Thanks again Emily.


ems...@mindspring.com

unread,
Nov 21, 2003, 10:18:37 PM11/21/03
to
"Gary Leighton" <leight...@hotmail.com> wrote in message news:<bpm3m3$hik$1...@titan.btinternet.com>...

> I just wanted to give a little bit more feedback than the "err, thanks" of
> the other day :)
>
> > T3 provides a fair amount of support for NPCs being able to interact
> > with the environment in basically the same way that the player does;
> > an NPC who tries to take a high object fails (unless programmed not
> > to) in just the same way, for instance. So that then you can give
> > NPCs a range of commands which they will be able to carry out in a
> > well-simulated way, and NPC action scripts become fairly
> > sophisticated.
>
> OK, but I would describe this as minimal support for goal-driven NPC's. But
> it does at least make it possible to re-use the existing NPC classes. I'm
> suprised that TADS & Inform don't do a bit more to support intelligent NPCs,
> out of the box.

Yes, it is minimal for what you want. On the other hand, it's hard to
figure out how much *further* you would want to go, in an out of the
box system. What kind of functionality does *everyone* want for their
NPCs? Pathfinding? Okay, maybe, but some games have fairly
discontinuous maps. Complex searching-for-objects ability? Again,
maybe, but exactly how that would work would probably vary a lot. I
think it's probably more useful to try to create this kind of thing as
extensions -- possibly complex systems of extensions.

The fact is that, beyond the very basic stuff, world models vary quite
a lot from game to game. Daniel Freas' "Erudition Chamber" apparently
had a sufficiently robust simulation of breakable objects, and
objects-that-break-things, that it provided some solutions he didn't
intend. Many game worlds don't provide that degree of complexity, but
some *do* account for other stuff -- fire, maybe, or liquid, or...
well, what the author decided to put in depends a lot on what the game
is about and how the player is meant to approach the puzzles. So
making goal-finding NPCs who dovetail with that is tricky. Besides
which, then you have the whole question of a conversation system and
communication, and getting your NPC behavior to mesh with *that* as
well...

> > The other thing you should look at, whether you're using TADS 2 or
> > Inform, is Nate Cull's Reactive Agent Planner extension, available for
> > either language. In fact, even if you choose to work in T3, a little
> > look at RAP would not be amiss. RAP is non-trivial to learn to use,
> > but once you've gotten past that, it will let you make goal-seeking
> > NPCs who develop sophisticated plans and react to changes in their
> > environment. I was able to put together some surprisingly active and
> > behaviorally interesting NPCs with it in a fairly short time.
>
> I've had a good read of the docs for RAP, and I'm impressed. I suppose that
> a fair amount of work is required from the designer to encode the necessary
> plans, but I expect you could do good things with this.
>
> Why isn't everyone using it?

I assume because it's damned hard, and even once you've figured out
how it works and have written modules that actually succeed, you wind
up with funky behavior sometimes as a result of the goal-finding
you've chosen to arrange.

As a test of the system, I once wrote up something where NPCs would
collect certain kinds of items (eg, one thing of the "weapon" class
and one thing of the "armor" class and so on) and then use these items
to perform a task. But -- though they walked around my little world,
opened containers, took objects, etc -- they acted kind of odd about
it. They always knew where to find things (programming to be
*ignorant* of objects until stumbling across them would be another big
heap of work) but, on the other hand, sometimes they would walk out of
the room where there was something that they needed, just because they
were working on another part of their goal at the moment. A really
intelligent agent would've thought, "hey, I'm gonna need that later"
and picked it up.

Now, all this is not RAP's fault; it's mine. But just because you can
get them to pursue their goals doesn't mean they pursue them
*convincingly* -- that's a bunch of extra effort to achieve.

The Despoiler

unread,
Nov 22, 2003, 6:09:31 AM11/22/03
to
I was shocked and illuminated when Gary Leighton wrote:

I've been developing an AI scripting language inspired by the RPG
script language developed by BioWare for the Baldur's Gate D&D engine.

If you have not yet studied this system and are serious about coding
an AI, do so NOW:

http://www.infinetivity.com/~jch/bg/ScriptCompiler.html

Bioware has been improving this system for Icewind Dale and
Neverwinter Nights, but to my knowledge, the only public release of
the SDK was for BG. If anyone knows differently, please correct me.

I would judge that about 0.01% of BG players actually tried to write
their own character scripts, so the public release idea was shelved.

Regardless, BioWare needed the system internally. The idea was to
build a robust AI language that could be handed off to the storyboard
game designers who could use it to craft the various monsters and
characters to populate the game universe.

Strong RPG elements in this particular implementation, but I think the
IF parallels are self-evident...

_____
The Despoiler

Thomas Hudson

unread,
Nov 23, 2003, 1:20:57 PM11/23/03
to
In article <3fbf3f8...@news1.sympatico.ca>,

The Despoiler <original...@yahoo.com> wrote:
>
>I've been developing an AI scripting language inspired by the RPG
>script language developed by BioWare for the Baldur's Gate D&D engine.
>
>If you have not yet studied this system and are serious about coding
>an AI, do so NOW:
>
>http://www.infinetivity.com/~jch/bg/ScriptCompiler.html
>
>Bioware has been improving this system for Icewind Dale and
>Neverwinter Nights, but to my knowledge, the only public release of
>the SDK was for BG. If anyone knows differently, please correct me.

It's all there in Neverwinter Nights, together with lots of community
work in extending/improving/adapting it.

Caveat: the people I thought were doing the best work in that
community were throwing it out to build their own AI systems based
on the underlying script language.

Tom

The Despoiler

unread,
Nov 23, 2003, 4:25:31 PM11/23/03
to
I was shocked and illuminated when Thomas Hudson wrote:

>It's all there in Neverwinter Nights, together with lots of community
>work in extending/improving/adapting it.
>
>Caveat: the people I thought were doing the best work in that
>community were throwing it out to build their own AI systems based
>on the underlying script language.

Glad to see the system is still evolving.

http://nwn.bioware.com/builders/sctutorial.html

Nevertheless, it remains a far cry from coding a convincing NPC,
summing down a character's personality to a choice of 9 alignments and
some hard coded event based reactions.

My AI system is far more ambitious.

( Although BG2 did introduce the possiblitiy of romantic involvement
between characters... )

_____
The Despoiler

Thomas Hudson

unread,
Nov 24, 2003, 7:49:44 AM11/24/03
to
In article <3fc12400...@news1.sympatico.ca>,

The Despoiler <original...@yahoo.com> wrote:
>I was shocked and illuminated when Thomas Hudson wrote:
>
>>It's all there in Neverwinter Nights, together with lots of community
>>work in extending/improving/adapting it.
>>
>>Caveat: the people I thought were doing the best work in that
>>community were throwing it out to build their own AI systems based
>>on the underlying script language.
>
>Glad to see the system is still evolving.
>
>http://nwn.bioware.com/builders/sctutorial.html
>
>Nevertheless, it remains a far cry from coding a convincing NPC,
>summing down a character's personality to a choice of 9 alignments and
>some hard coded event based reactions.

You must be skimming, or have a different definition of personality than
me - there's also a large tree-based conversation system moderately well
integrated with the scripting language. Every branch in the tree has
scripts that control whether or not it's available and scripts that fire
after it executes.

(Also, the documentation on Bioware's site is out of date. Again,
fan-written docs are much, much better. Look for the "NWN Lexicon"
project for a usable reference manual and some interesting tutorials.)

So, just as in BG2, there's plenty of room for romantic involvement.
Again, Bioware did a lousy job of it; some community members have done
a better job using the same tools. Nothing as convincing as Emily Short's
work yet, though. :)

Back to trying to write any of several THINGs (stories? adventures?)
that are too adventuregamey for NWN but seem too broad in scope for IF,

Tom

The Despoiler

unread,
Nov 24, 2003, 7:30:38 PM11/24/03
to
I was shocked and illuminated when Thomas Hudson wrote:

>>http://nwn.bioware.com/builders/sctutorial.html
>>
>>Nevertheless, it remains a far cry from coding a convincing NPC,
>>summing down a character's personality to a choice of 9 alignments and
>>some hard coded event based reactions.
>
>You must be skimming, or have a different definition of personality than
>me - there's also a large tree-based conversation system moderately well
>integrated with the scripting language. Every branch in the tree has
>scripts that control whether or not it's available and scripts that fire
>after it executes.

True, I only skimmed over this information quickly and my statement
was probably unfair.

However, let me propose a benchmark:

Give me an AI API that let's me model the following distinct
personalities:

War Minister Klaus Wehrkeit
Coffers Minister Argento Rico
Christ Minister Pierre Bonfleche
Interior Minister Variola Modo
Ambassador to China Marco Pulisci
Prince Louis
Queen Sarah
Miss Sierra
And, of course, Palace Minister Varicella

Each one complete with the intelligence to carry out his own master
plan for power, while reacting to and thwarting his rivals' attempts,
such that the player could be given the choice to play any one of the
nine and match wits against his opponents.

_____
The Despoiler

Kevin Venzke

unread,
Nov 24, 2003, 9:05:07 PM11/24/03
to
"The Despoiler" <original...@yahoo.com> wrote in message
news:3fc29ea0...@news1.sympatico.ca...

> However, let me propose a benchmark:
>
> Give me an AI API that let's me model the following distinct
> personalities:
>
> ...

> Miss Sierra
> And, of course, Palace Minister Varicella
>
> Each one complete with the intelligence to carry out his own master
> plan for power, while reacting to and thwarting his rivals' attempts,
> such that the player could be given the choice to play any one of the
> nine and match wits against his opponents.

You have just described "Kiss Chase," except without any Aztecs.

But seriously, won't you have a hard time crafting "intelligence" without
manually programming each AI character to know how to use every
item in the game?

Kevin Venzke


Shadow Wolf

unread,
Nov 25, 2003, 12:38:57 PM11/25/03
to
original...@yahoo.com (The Despoiler) wrote in
news:3fc29ea0...@news1.sympatico.ca:

Trivial. Just use RAIF-pool, it's all handled automatically ;-)

--
Shadow Wolf
shadow_wolf1 at hotpop dot com
Stories at http://www.asstr.org/~Shadow_Wolf
AIF at http://www.geocities.com/shadowolf3400

ems...@mindspring.com

unread,
Nov 25, 2003, 5:39:25 PM11/25/03
to
Daniel Barkalow <iabe...@iabervon.org> wrote in message news:<Pine.LNX.4.21.031121...@iabervon.org>...

For "modification of the Inform library" understand "complete
replacement not compatible with the original library". You can read
about it here

http://homepage.ntlworld.com/elvwood/InteractiveFiction/Platypus/

I think I heard from Nate that he had made a Platypus version of RAP,
too. So maybe Platypus is the only system where you get both
consistent action handling and an available version of RAP. The down
side is that Platypus has fewer other extensions than standard-library
Inform, and I'm not sure how much energy its creator (Anson Turner) is
putting into maintaining it these days. (Not an implied criticism: I
really don't know. It's entirely possible he's been working on it a
lot.)

-- Emily

Reply all
Reply to author
Forward
0 new messages