[MUD-Dev] Stack-Based NPC AI

Eli Stevens {KiZurich} c718157 at showme.missouri.edu
Sun Dec 6 16:37:54 CET 1998


[Emil Eifrem, Re: Spell components, chemistry and the like...]
> I've never played on a mud that has an AI worth mentioning. :(

This statement (which was made some time ago, I should add) got me =
thinking
on ways to design a simple, yet powerful "tasking" (for lack of a better
word) system for a MUD=92s mobs.  I had read on the web about using a =
stack to
simulate a mob=92s priorities, and was wondering if anyone here had =
attempted=20
(successfully or not) to design/implement anything like what I describe =
below.
(Please note that I assume the MUD has a system in place for mobs to =
find=20
their way to a given room, mobile, or player.)

Every mob would have a "base state" that makes them act a certain way =
when
they have nothing else on their to-do stack.  There would also be =
triggers
that would push a new to-do action onto the stack.  When that action was
finished, it would pop itself off of the stack, allowing whatever was
beneath it on the stack to be done.

Ex: A thief mob in a large city might have a base state of "wander
aimlessly" that would move the mob slowly from room to room.  One of the
triggers for the thief might be "when in the same room as a player (or =
mob,
if you don=92t mind the NPCs robbing each other :)."  That trigger would =
then
push two actions onto the stack (in this order): "avoid player" and "rob
player."

The to-do stack would then look like this:
   -- top --
   rob player
   avoid player
   base: wander

Since the stack now says to rob the player, the mob would attempt to =
pick
the player's pocket.  Most likely, the thief would not want to hang =
around
the crime scene, so the mob would then attempt to move away from the =
player,
as per "avoid player."

A second trigger could fire "when attacked by a player/mob."  (Which =
would
most likely happen if the robbery failed/was noticed.)  This would push:
"kill player," "find player," "group friendly mob," "find friendly mob,"
"flee player."  The stack now looks like this:

   -- top --
   flee player
   find friendly mob  \ note that these could be repeatedly pushed to
   group friendly mob / find several friendly mobs
   find player
   kill player
   avoid player
   base: wander

To the player the situation looks like this: they walk into a room, and =
fend
off a prospective bandit.  The bandit would run away, only to reappear =
in a
few minutes with friends, who all try and beat the tar out of the =
player,
unless the player manages to kill the thief before the thief can get to
his/her friends.

---

It seems to me that with some imaginative coding, and careful thought
to the triggers and actions, a very realistic-ish world could be set
up...  Of course, if there are not enough triggers and actions, the
mobs might all act the same, but that's better than nothing, right?

Anyway, if anyone has any ideas or experience, I personally would be
interested in hearing about it, and I suspect that the list would too.

Silence is an empty stack
Eli - c718157 at showme.missouri.edu

P.S.- This is my first post, can't you tell?  :)






More information about the mud-dev-archive mailing list