[MUD-Dev] optimizing code

&lt &lt
Mon Feb 8 22:31:30 New Zealand Daylight Time 1999


This is in reply largely to a recent post by Mr. Gray. In it, he mentioned
that a significant part of his processor overhead was due to his 150
mobiles all moving about every 2 seconds.

Mobile ai is the biggest pain in my neck, and I'd love to hear ideas on
how to improve them generally while retaining most or all of the
functionality.

Essentially, our mobiles have two "timers" attached to them. One covers
attacking and one covers most other things. Every half-second, the code
decrements each timer on every mobile. If the timer is up, it checks to
see if the mobile should be doing something (either attacking someone or
doing whatever else). Now, our actual routines are not that complicated.
Quite a few mobiles (mountain lions, elk, rabbits, thugs in the sewers,
etc) wander around randomly, but other than that, mobiles that are not
directly involved with a player (and aren't wounded or whatnot) don't do
much.

I cannot really think of a better way to do this in principle and I'm
wondering if any of you can. I use a custom language and compiler, so keep
that in mind when offering language-specific suggestions. I'm sure some of
you clever coders out there have much better ways of doing things, and I'm
sure many of us could benefit from your knowledge. Thanks!

--matt






More information about the MUD-Dev mailing list