Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Some suggestions/help for my monster AI

17 views
Skip to first unread message

Timothy Pruett

unread,
Mar 29, 2005, 10:08:52 PM3/29/05
to
I'm at the point in my current project where the groundwork is all
laid out, I/O finished, Lua tied in, rudimentary file reading/writing,
player essentials implemented, and monster framework set up. As of
now, I can walk around, and attack monsters in melee, although they
don't attack back yet. Honestly, despite the fact that I can't do
much yet in the current version, I'm pretty happy with it's progress,
since all that's really left to do is start scripting/level building.
A few features left besides that, but not much more. And, I'm at
the point where the main thing I want to start working on is my
monster AI.

I'm going to script the AI in Lua, to provide maximum flexibility.
I'm not too concerned with the AI implementation, because I feel
confident I can handle it. I am, however, running out of interesting
ideas for AI variations. Rather than attempting to design some
overwhelmingly complex, "brilliant" AI, to cover every possibility,
I've decided I want to code up some nice, simple AI modules, tailored
to particular behavior patterns.

Well, I've got a few ideas for behavior patterns, but not many, and
lacking in variety. I feel somewhat wierd for running out of ideas,
since that seems to be the one thing RL developers _don't_ do. This
newsgroup almost always produces far more ideas than actual code,
which is a good thing. But, well, I'm running on dry here. Yeah,
sad, I know. So allow me to list what modules I've thought up so far,
and anyone with advice, *please* post it. It'd be much appreciated. :)

Behavior Patterns
-----------------

*note -- All the monster's can take into account allied strength,
which is factored into their own when comparing against a percieved enemy.

Typical -- Attack percieved enemies with percieved strength lower than
or equal to own. When wounded to a certain point, attempt retreat.
If retreat is impossible, attempt to attack with full force (berzerk).

Scavenger -- Avoid enemies with percieved strength within certain
percent of own, but follow within certain distance. Attack enemies if
they are weakened. If valuables/food is found, take it. If wounded
lightly, retreat.

Coward -- Run from any enemy, no matter what. Only fight back when
cornered.

Patrol -- Patrol specified area, until enemy presence is detected.
When enemy is detected, attack. Other than the patroling part, the
rest of this module is identical to the Typical module.

Special -- Specially scripted AI for unique enemies, bosses, and
townsfolk.

And as sad as it may be, that's all I can think of. I could probably
get by on just that, but I'd really like to kick it up a notch, since
having only these modules would make things to predictably easy,
eventually. *Please* toss me some ideas for behaviors to add!

As always, any help or comments will be greatly appreciated! :)


--
"There are of course many problems connected with life, of
which some of the most popular are `Why are people born?'
`Why do they die?' `Why do they spend so much of the
intervening time wearing digital watches?'"

-- The Book.

Antoine

unread,
Mar 29, 2005, 10:26:19 PM3/29/05
to

Personally, I got my monster AI ideas by sitting down, thinking of a
list of monsters I'd like to have, and figuring out how I'd like each
one to behave.

For example: I decided to include goblin archers. Well, I figured they
will shoot you if they can, and try to get LOS if they can't. If you
try to melee them, of course they should try and run away. Not much
sense in sticking round to get pasted. And since I want them to stay in
groups rather than wandering round getting split up, they will stay put
until they first sense the PCs.

The next monster on my list was skeleton warriors... well, skeletons
will chase you, attack you, never retreat, never go berserk, that's
another AI type, and so it goes.

A.

P.S. Go easy on monsters retreating when wounded, which you include in
your 'typical' AI. It can be quite annoying for the player if too many
monsters do it.

Auric__

unread,
Mar 29, 2005, 10:43:40 PM3/29/05
to

Insane -- Always attack the enemy, no matter how strong it is, and fight
until death. (Standard hack-n-slash game AI)

Coward 2 -- Hide from the enemy, and later attack from the enemy's blind
side. (D&D thief)

Long-range -- Attempt to keep the enemy from getting close, while
attacking with ranged attacks.

OTOH, I agree with Antoine - rather than generic AIs, I prefer specific
AIs.
--
auric underscore underscore at hotmail dot com
*****
Every nonzero finite dimensional inner product space has an orthonormal
basis. It makes sense, when you don't think about it.

Timothy Pruett

unread,
Mar 29, 2005, 10:51:54 PM3/29/05
to
Auric__ wrote:

<snip>

> Insane -- Always attack the enemy, no matter how strong it is, and fight
> until death. (Standard hack-n-slash game AI)
>
> Coward 2 -- Hide from the enemy, and later attack from the enemy's blind
> side. (D&D thief)
>
> Long-range -- Attempt to keep the enemy from getting close, while
> attacking with ranged attacks.
>
> OTOH, I agree with Antoine - rather than generic AIs, I prefer specific
> AIs.

I like your suggestions (even though I'm still kicking myself for not
already having those :) ).

Also, I think these are pretty specific AIs. Far more specific than
most RLs, where the only AI consists of monsters beelining towards the
player, and attacking him until they die. And, while I like Antoine's
suggestions, and definitely appreciate the alternate way of figuring
out new behavior patterns (based on specific enemies), but I myself
want to avoid designing individual AI routines for every single enemy.
If I modularize them right, it should be possible to just include
all the modules I want for a specific enemy, and sort of build the AI
up from parts.

Auric__

unread,
Mar 29, 2005, 11:30:46 PM3/29/05
to
On Tue, 29 Mar 2005 22:51:54 -0500, Timothy Pruett
<drakalor...@gmail.com> wrote:

>Auric__ wrote:
>
><snip>
>
>> Insane -- Always attack the enemy, no matter how strong it is, and fight
>> until death. (Standard hack-n-slash game AI)
>>
>> Coward 2 -- Hide from the enemy, and later attack from the enemy's blind
>> side. (D&D thief)
>>
>> Long-range -- Attempt to keep the enemy from getting close, while
>> attacking with ranged attacks.
>>
>> OTOH, I agree with Antoine - rather than generic AIs, I prefer specific
>> AIs.
>
>I like your suggestions (even though I'm still kicking myself for not
>already having those :) ).

More:
Trapper -- lays a trap and waits for the enemy to walk into it, only
entering actual combat if the enemy isn't killed by the trap.

Experienced -- fights with good tactics: if wounded to a certain point,
will use healing magic/potions on self; fights cautiously but not
cowardly, if outmatched, attempts to bargain its way out; etc.

>Also, I think these are pretty specific AIs. Far more specific than
>most RLs, where the only AI consists of monsters beelining towards the
>player, and attacking him until they die. And, while I like Antoine's
>suggestions, and definitely appreciate the alternate way of figuring
>out new behavior patterns (based on specific enemies), but I myself
>want to avoid designing individual AI routines for every single enemy.
> If I modularize them right, it should be possible to just include
>all the modules I want for a specific enemy, and sort of build the AI
>up from parts.

Since your AIs are able to tell when they're in a group, you might want
to think about group tactics:
- flanking maneuvers: goblins attack you from both sides!
- ambushes: a buncha goblins jump down from a ledge, landing on your
head!
- false retreats: (variation on ambush) the goblins run away! oh, wait,
they just led you to another dozen goblins...
- overwhelming numbers: you are attacked by a hundred goblins!
- hit-n-run tactics: the goblins hit you for X damage! the goblins run
away! [later] the goblins return!
- relief combatants: you hit goblin A for X damage! goblin A retreats!
you are attacked by goblin B! goblin A drinks a healing potion!
- etc.


--
auric underscore underscore at hotmail dot com
*****

The bugs will go away when you turn off the computer!

Antoine

unread,
Mar 29, 2005, 11:42:28 PM3/29/05
to

...Wouldn't one hope that a thief would steal stuff rather than just
attacking??

> Long-range -- Attempt to keep the enemy from getting close, while
> attacking with ranged attacks.
>
> OTOH, I agree with Antoine - rather than generic AIs, I prefer
specific
> AIs.

Although having written a specific AI, you can then reuse it for a
similar monster at a later stage... a zombie might well behave very
similarly to a skeleton...

Timothy Pruett

unread,
Mar 29, 2005, 11:44:39 PM3/29/05
to
Antoine wrote:

<snip>

> Although having written a specific AI, you can then reuse it for a
> similar monster at a later stage... a zombie might well behave very
> similarly to a skeleton...

Good point. Gotta keep that in mind.

Timothy Pruett

unread,
Mar 29, 2005, 11:47:57 PM3/29/05
to

Some more nice suggestions! Group tactics can always lead to some
fun, and memorable experiences. Combining ambushes with hit-n-run
could provide some very cool encounters.

R. Dan Henry

unread,
Apr 3, 2005, 7:04:12 PM4/3/05
to
On Tue, 29 Mar 2005 22:08:52 -0500, Timothy Pruett
<drakalor...@gmail.com> wrote:


>Behavior Patterns
>-----------------
>
>*note -- All the monster's can take into account allied strength,
>which is factored into their own when comparing against a percieved enemy.
>
>Typical -- Attack percieved enemies with percieved strength lower than
>or equal to own. When wounded to a certain point, attempt retreat.
>If retreat is impossible, attempt to attack with full force (berzerk).

Daredevil -- Defends if attacked or allies attacked, but only
initiates combat if forces are "close enough" to equal. Represents
groups that fight to prove courage; suicidal attacks are still stupid,
but an attack with a strong advantage shows no heroism, so is
pointless.

Greedy -- Largely ignores target strength. Attacks if target appears
wealthy (including obvious magic goodies, like flaming sword).

Fanatic -- Ignores others unless they break a religious taboo (so each
Fanatic type needs AI modified for different taboos), then makes
berserk attacks.

R. Dan Henry
danh...@inreach.com

Twisted One

unread,
Apr 4, 2005, 3:19:33 AM4/4/05
to
R. Dan Henry wrote:
> Fanatic -- Ignores others unless they break a religious taboo (so each
> Fanatic type needs AI modified for different taboos), then makes
> berserk attacks.

Real Fanatic -- Ignores others unless they break a taboo, and then
hijacks an airliner and flies it into the nearest large landmark, even
though said landmark has nothing to do with the broken taboo.

That way people can have the pleasure of downloading your game and
killing Mohammed Atta over and over again. :)

--
http://www.gnu.org/philosophy/right-to-read.html
Palladium? Trusted Computing? DRM? Microsoft? Sauron.
"One ring to rule them all, one ring to find them
One ring to bring them all, and in the darkness bind them."

Hansjoerg Malthaner

unread,
Apr 4, 2005, 8:10:44 AM4/4/05
to
Timothy Pruett wrote::

> I'm at the point in my current project where the groundwork is all laid
> out, I/O finished, Lua tied in, rudimentary file reading/writing, player
> essentials implemented, and monster framework set up. As of now, I can
> walk around, and attack monsters in melee, although they don't attack
> back yet. Honestly, despite the fact that I can't do much yet in the
> current version, I'm pretty happy with it's progress, since all that's
> really left to do is start scripting/level building. A few features
> left besides that, but not much more. And, I'm at the point where the
> main thing I want to start working on is my monster AI.

Maybe this can give you a few ideas:
http://h-world.simugraph.com/pmwiki/pmwiki.php?n=Library.Beings

Look up the AI section of that page.

--
c.u. Hajo

Risto Saarelma

unread,
Apr 1, 2005, 8:29:28 AM4/1/05
to
On 2005-03-30, Auric__ <not.m...@email.address> wrote:
> Experienced -- fights with good tactics: if wounded to a certain point,
> will use healing magic/potions on self; fights cautiously but not
> cowardly, if outmatched, attempts to bargain its way out; etc.

As an aside, how is bargaining exactly going to work? I'm assuming that
the creatures will be fighting the player. If the player is strong
enough to defeat the creature, why would the player accept a bribe to
stop fighting when it is possible to just kill the creature and take
whatever it has?

Of course the game system can cheat so that if you accept the abyssal
knight's surrender, you get a bag of gems, but if you just go ahead and
kill him you only find a rusted longsword on the corpse and never see
the bribe. But let's suppose we like the gameworld consistent (avoiding
the evil r-word here), and only allow the creatures to offer items which
are actually in their inventory. Now accepting the surrender only makes
sense if continuing to fight the creature would be sufficiently
expensive or dangerous so that the player would rather let the creature
get away. But since we are probably dealing with a powerful creature
here (the player will just kill weak bargainers), it doesn't make much
sense to let it get away and get a chance to strike again. So it's best
for the player to try to kill the creature regardless of the offer to
surrender.

But this is just the traditional hack'n'slash game paradigm. A game
where surrendering is a sensible option might be more interesting.
Perhaps there could be some kind of chivalry code which expects you to
accept a surrender. Killing foes who tried to surrender would cause you
to lose honor. Whether this would mean lessened divine favor, scorn from
some npcs or just a note in the character's conduct is up to the game
system. Players who fight honorably might also have a better chance of
surviving when surrendering themselves to a more powerful enemy,
assuming the enemy also follows the chivalric tradition.

Such a system would make a very different game than most roguelikes. The
standard assumption is that enemies are more or less mindless monsters.
Some might be humans, but this basically means that they can open doors
and use tools. In nethack, a soldier has pretty much the same
psychological complexity as an acid blob. What if we assumed that
fighting other humans or humanoids is the norm, and there would be all
sorts of martial traditions in the world?

On the other hand, maybe the hack'n'slash game is the sort of nice and
uncomplicated thing people want. Going to a goblin dwelling, hacking
wave upon wave of screaming, mindless goblins into pulp and looting
their treasure gives one a warm and heroic feeling. On the other hand if
the goblins aren't mindless, figure out that the player can easily kill
them all and offer to give all their gold so that the player will let
them escape alive, the player might end up feeling like a thug instead
of a champion of valor, virtue and smashing things to bloody pulp.

--
Risto Saarelma

Lauri Vallo

unread,
Apr 5, 2005, 12:57:17 PM4/5/05
to
On Fri, 1 Apr 2005 13:29:28 +0000 (UTC), Risto Saarelma wrote:

>Of course the game system can cheat so that if you accept the abyssal
>knight's surrender, you get a bag of gems, but if you just go ahead and
>kill him you only find a rusted longsword on the corpse and never see
>the bribe. But let's suppose we like the gameworld consistent (avoiding
>the evil r-word here), and only allow the creatures to offer items which
>are actually in their inventory. Now accepting the surrender only makes
>sense if continuing to fight the creature would be sufficiently
>expensive or dangerous so that the player would rather let the creature
>get away. But since we are probably dealing with a powerful creature
>here (the player will just kill weak bargainers), it doesn't make much
>sense to let it get away and get a chance to strike again. So it's best
>for the player to try to kill the creature regardless of the offer to
>surrender.

Maybe the knight isn't carrying all his riches with him, but has them
at home or in a secret stash.
Then again.. there might be a weapon in the stash too, or a healing
potion.

Now.. if you manage to kill the knight who has surprised you like
this, you get some treasure.

0 new messages