[MUD-Dev] CORBA, RMI, threads

coder at ibm.net coder at ibm.net
Thu Feb 12 14:09:27 CET 1998


On 24/01/98 at 07:35 PM, Caliban Tiresias Darklock <caliban at darklock.com>
said: >Vadim Tkachenko wrote:
>> Marc Eyrignoux wrote:

>> > In fact, I intend to make the monsters act every 15 seconds. A thread
>> > that would sleep for 15 seconds and acts according to the situation 
>> > at the moment it wakes up seems to be a good way for doing this.
>>
>> Once again, why 15? Why not 14 or 16?

>12 | (<unique object reference number> & 3) would work. Give the
>appearance of randomness and 1-second resolution, without bogging the CPU
>by using all the threads at once. 

Players will very quickly learn the granularity.  They'll snoop, remote
watch, or otherwise see a mobile "do" something, and then know that they
are safe for at least 15 seconds to do whatever they want before they need
get out.  I've done this more than once with different games.

>Using appropriate bit shifting and
>arbitrary fragments of statistics and whatnot, you can do a really fast
>calculation that would change over time and keep things separated a good
>deal. Sure, you might end up with a pathological case, but that would be
>rare and it wouldn't be any worse than scheduling all the threads at
>once.

Better, but the problem of the same base granularity remains.

>There are, of course, much more efficient methods that could be pulled up
>by people who are much more experienced in this sort of programming than
>I am. 

I'f you are wedded to the pulse/polling model for whatever reason I'd
instead tend to have a loop which iterates across all possible candidates
a say one N'th the intended action frequency, and randomly selects N% of
the candidates on each pass for activity.  (Play with the numbers until
you like them)  The intended result is that every (say) 3 seconds a given
object may or may not get evaluated, with the strong possibility that some
oblects will be ignored for extensive periods, and others hyper-active. 
Tailoring your pseudo-random number algorithm can change the shape of the
curve here.

--
J C Lawrence                               Internet: claw at null.net
----------(*)                              Internet: coder at ibm.net
...Honourary Member of Clan McFud -- Teamer's Avenging Monolith...




More information about the mud-dev-archive mailing list