[MUD-Dev] Re: Stack-Based NPC AI

Richard Woolcock KaVir at dial.pipex.com
Mon Dec 7 01:04:06 New Zealand Daylight Time 1998

Eli Stevens (KiZurich) wrote:
> [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’s mobs.  I had read on the web about using a stack to
> simulate a mob’s priorities, and was wondering if anyone here had attempted
> (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
> their way to a given room, mobile, or player.)

[snip example stack-based system]

The simplest solutions I've seen are purely state-based.  Each mob can be
in one of a number of states, each of which can lead on to other states.
Imagine an animal such as a wolf, for example:

   If being attacked, attack person back
   If hurt, lick wounds
   If thirsty, drink
   If hungry, eat
   If tired, sleep
When sleeping:
   If attacked, wake up (default state)
   If hungry or thirsty, wake up (default state)
   If no longer tired, wake up (default state)
When eating:
   If being attacked, attack person back
   If more thirsty than hungry, start drinking
   If no longer hungry, go back to default state
When drinking:
   If being attacked, attack person back
   If more hungry than thirsty, start eating
   If no longer thirsty, go back to default state
When fighting:
   If losing, try and run away

Once you have something simple like that in place, you can start
making the code a little more complex - the wolf might have to 
hunt down other animals for example, or perhaps she brings back
food for her pups.

The only advantage a stack-based system has over a state-based
system is that the former method allows mobs to 'remember'
situations they were previously doing and go back to them at a 
later point - but for animal-level intelligence, I don't think 
that would be necessary.

If you're planning immitation of human-level intelligence, your
greatest problem is going to be mob speech.  You could also
store the 'memory' as a list rather than a stack, so that things 
can be inserted - thus allowing mobs to plan things ahead (next
week, Bubba has to go and pay his Council Tax).


More information about the MUD-Dev mailing list