Unpredictable NPCs? Good/bad?

8 views
Skip to first unread message

Duane D Morin

unread,
Feb 20, 1995, 10:46:58 AM2/20/95
to
I'm working on an experiment right now to train NPCs how to interact with
a textadventure world. My goal is to create a character that, while it
wouldn't necessarily solve any puzzles or win the game, would act
consistently within the game (i.e. would eat when it gets hungry, would
attack when attacked, etc..) The interesting twist, here, would be that
the NPC is neither random, nor is it pre-programmed to respond a given
way to a given action. Say that there is a room in which the exit to the
north is blocked by a large boulder, that the player cannot move. However,
we've seen a friendly looking troll wandering around the caves who
probably could. How does the player get the troll to help? Probably by
feeding him, and having him follow the player back to the cave, upon
which he is told "Troll, move boulder" and promptly does it.

This is quaint. But this could just as easily have been pre-programmed.

What if the troll isn't hungry when you feed him? What if you can't find
him? What if you already kicked him in the shins once, and he doesn't
like you anymore? What if, in order to get even this far, you needed to
locate the key, which the troll has already decided was particularly tasty?
In the game I envision, any of the above could happen. Probably even more.

Personally, I find it cool to think that there are influences in the game
running independent of my own actions. Makes it more interesting. The
problem, of course, is that this could present unsolvable problems.
(Say that, on the other side of the entrance in the above example, a rockslide
triggers and seals off the passage back. Now imagine if the troll had
gotten to this room first.)

I guess the question, then, is: Is this tolerable? Obviously, there
couldn't be all that many unsolvable problems. (Good writing could
technically make it zero problems, always having a way out that isn't dependent
on the NPCs). And, of course, there would be a number of traditional,
scripted NPCs mixed in as well that could be depended upon to act
deterministically.

I'm a big proponent of alife, and emergent behavior. If I program a
character in such a way that it does something I didn't expect, it's a win.
I like the idea of a learning NPC, because I can lift it wholesale out of
one game, and plunk it down in another, and have it automatically continue
its knowledge gathering. For example, it may have learned in game one,
after lots of trying and failing and reasoning, that objects belonging
to the class is-contained-by-tree are edible (since everything in the
last game that he took from a tree was edible). He now knows this, so
the first apple tree he comes across in the new game, he can pick a few
nice ones. Of course, to be fair, the tree in this game could grow poisonous
doodleberries, and if he eats one, he'll die. Well, yeah. It would
then be the programmer's decision whether or not to give him the gift
of past life learning (such as any human player would have), or just let him
continue to be reborn, eat the damn things, and die again, until something
interrupted the loop. (Of course, this only works if I stay world consistent.
If the NPC has learned something about physics, then the laws of physics
should remain constant.)

Duane

Fredrik Ekman

unread,
Feb 21, 1995, 9:12:36 AM2/21/95
to
In article <D4B2I...@world.std.com> dmo...@world.std.com (Duane D Morin) writes:

I'm working on an experiment right now to train NPCs how to interact with
a textadventure world. My goal is to create a character that, while it
wouldn't necessarily solve any puzzles or win the game, would act
consistently within the game (i.e. would eat when it gets hungry, would
attack when attacked, etc..) The interesting twist, here, would be that
the NPC is neither random, nor is it pre-programmed to respond a given
way to a given action. Say that there is a room in which the exit to the
north is blocked by a large boulder, that the player cannot move. However,
we've seen a friendly looking troll wandering around the caves who
probably could. How does the player get the troll to help? Probably by
feeding him, and having him follow the player back to the cave, upon
which he is told "Troll, move boulder" and promptly does it.

Wonderful! I recently tried to do something similar in PROLOG, but finally
had to give in due to the limitations of my age-old compiler. Anyway, if
only a suitable language was found, I think it would be very interesting,
and probably a good thing for the player as well.

My scheme was, basically, as follows: The player needs to get through a
locked door. The player is too weak to bash it and there is no key. The
NPC troll, however, (yes, I had a troll, too) was strong enough, and was
so simply programmed that he would do anything told by someone he thought
to be a friend. To make friends with the troll, the player had to give him
something the troll thought valuable (in this case a club). There were a
few other NPCs and plot twists too.

All the NPCs (and the PC, for that matter) were loosely based on Shoham's
Agent Oriented Programming approach, but without the time aspect. Thus, my
NPCs (agents) could neither plan nor remember past events. They only had
their knowledge base which could be added to or retracted from.

/F

Duane D Morin

unread,
Feb 21, 1995, 10:44:13 AM2/21/95
to
In article <EKMAN.95F...@rudolf.lysator.liu.se>,

Fredrik Ekman <ek...@lysator.liu.se> wrote:
>Wonderful! I recently tried to do something similar in PROLOG, but finally
>had to give in due to the limitations of my age-old compiler. Anyway, if
>only a suitable language was found, I think it would be very interesting,
>and probably a good thing for the player as well.

Currently writing in C++, but the first thing I decided was that the
knowledge base should be in LisP. So it's going to have a lisp interpreter
built in.

>My scheme was, basically, as follows: The player needs to get through a
>locked door. The player is too weak to bash it and there is no key. The
>NPC troll, however, (yes, I had a troll, too) was strong enough, and was
>so simply programmed that he would do anything told by someone he thought
>to be a friend. To make friends with the troll, the player had to give him
>something the troll thought valuable (in this case a club). There were a
>few other NPCs and plot twists too.

Well, to start, I think my troll would be about as simple. But since I'm
not sure how you programmed yours, I don't know how comparable our
methods would be. One event, player gives troll cube, would result in
the creation of fact "Player is friend" (for example) in the knowledge
base. Later, if the player attempts to tell the troll what to do, the
existence of this fact would dictate whether or not the troll complied.
Of course, if the player kicks the troll, then we could either eliminate
this fact from the knowledge base, change it to a negative, or just
assert "Player is not a friend" in there as well and give each a weight
(since he kicked him more recently then he fed him).

>Thus, my NPCs (agents) could neither plan nor remember past events.

I'd like to do something with a knowledge base such that the NPC would
store the state (everything it knows about) an object, about itself,
and about it's surroundings. Then it performs an action with the given
object, and looks for changes in each state. This is just wishful
thinking at the moment, though.

>They only had
>their knowledge base which could be added to or retracted from.

This can be a powerful thing, particularly if you add some reasoning based
on known facts. Say it learned fact "Apple is-contained-by tree" by
examining the apple. And say it learned "Apple is-edible" by trying to eat
it and seeing that its hunger went down. Now say it discovered the
same facts about oranges. It should be able to reason that
if X is-contained-by tree, then X is-edible, and he won't have to waste
time learning about bananas when he finds one. Of course, not everything
that is-contained-by tree is necessarily edible, but he'll learn that later.

Duane

Fredrik Ekman

unread,
Feb 23, 1995, 7:09:08 AM2/23/95
to
In article <D4Cx1...@world.std.com> dmo...@world.std.com (Duane D Morin) writes:

Currently writing in C++, but the first thing I decided was that the
knowledge base should be in LisP. So it's going to have a lisp interpreter
built in.

I know neither, and it sounds like a lot of work anyway. However, I would
be interested in seeing your source once you have something workable.

>My scheme was, basically, as follows: The player needs to get through a
>locked door. The player is too weak to bash it and there is no key. The
>NPC troll, however, (yes, I had a troll, too) was strong enough, and was
>so simply programmed that he would do anything told by someone he thought
>to be a friend. To make friends with the troll, the player had to give him
>something the troll thought valuable (in this case a club). There were a
>few other NPCs and plot twists too.

Well, to start, I think my troll would be about as simple. But since I'm
not sure how you programmed yours, I don't know how comparable our
methods would be. One event, player gives troll cube, would result in
the creation of fact "Player is friend" (for example) in the knowledge
base. Later, if the player attempts to tell the troll what to do, the
existence of this fact would dictate whether or not the troll complied.

We're on exactly the same track here. In my prolog database the fact
would have been fact(troll, is(player, friend)) or something similar
('twas some time since I actually worked on this). If the player attacked
the troll, this fact would be retracted (which is where I found one of my
main implementation problems, due to my TurboPROLOG) and fact(troll,
is(player, enemy)) would be asserted in its place. This would cause the
troll to attack the player in turn.

To carry the discussion a little further, I would like to introduce a new
term: The Non-Player Agent (or NPA for short). This is just a special
case of NPC, which differs from other NPCs in that it has all its logics
separate from the main program. This does not necessarily mean that it
has to be knowledge-based. That is another special case of the special
case, so to say.

I would like to base my NPAs on two main features. Firstly on Shoham's
Agent Oriented Programming approach, which I mentioned in my previous
post (will post short summary and bibliographical info as soon as I find
the *&*%#$@ thing). Secondly on a kind of treat-based principle. Each
NPA has a set of treats, such as preceptiveness, greediness and
talkativeness. Perhaps also variable treats, such as mood. This would
allow the logic of ALL NPAs in one game (in one game engine, even) to be
inherited from the same super-NPA, based on these treats. The calculation
of a result based on the logic and the treats could be slightly based on
chance also to make it less likely that the player figures out the under-
lying processes.

/F

Rob Moser

unread,
Feb 27, 1995, 12:58:56 AM2/27/95
to
You guys (and anyone else interested in realistic independent characters in
IF) should have a look at the Oz project at Carnegie Mellon, if you haven't
already.

<http://www.cs.cmu.edu:8001/afs/cs.cmu.edu/project/oz/web/oz.html>

- Rob.

Duane D Morin

unread,
Feb 27, 1995, 8:22:22 AM2/27/95
to

Been there, seen that. Got a few of the white papers. :) The bit about
the cat was interesting, I thought.

Btw, you should get your mailer to put something other that "moser" in your
From: line up there. I tried to respond to one of your messages a few days
ago and couldn't find you.

Duane

Fredrik Ekman

unread,
Mar 1, 1995, 11:19:59 AM3/1/95
to
In article <EKMAN.95F...@rune.lysator.liu.se> I write:

I would like to base my NPAs on two main features. Firstly on Shoham's
Agent Oriented Programming approach, which I mentioned in my previous
post (will post short summary and bibliographical info as soon as I find
the *&*%#$@ thing). Secondly on a kind of treat-based principle. Each
NPA has a set of treats, such as preceptiveness, greediness and
talkativeness. Perhaps also variable treats, such as mood. This would
allow the logic of ALL NPAs in one game (in one game engine, even) to be
inherited from the same super-NPA, based on these treats. The calculation
of a result based on the logic and the treats could be slightly based on
chance also to make it less likely that the player figures out the under-
lying processes.

You see, I have just about forgotten about the Shoham source info. This
is mainly to remind myself to post it next time I read news. Also, like
a couple of people have kindly pointed out, I do indeed mean to say
"traits" rather than "treats" in the above paragraph. It's been far too
long since I studied psychology.

/F

Reply all
Reply to author
Forward
0 new messages