[MUD-Dev] Ticks?

Matt Mihaly the_logos at achaea.com
Tue Jun 11 17:08:13 CEST 2002


On Sun, 9 Jun 2002, Tand'a-ur wrote:
> "Anderson, David" wrote:
  
>> What have other people done for regenning?  I'm just doing my
>> best to have it make a bit more sense.
 
> Some muds have multiple pulses besides the main tick. Like you
> could do every second or so there is the health update
> pulse. Other things that need updating could have other length of
> pulses. What I do is try to figure out how often something needs
> to happen, and how cpu intensive the task is.

Have to admit I'm not even sure what you mean by a tick, but if I
understand it, in a lot of MUDs, character and monster state changes
are tied to a central ticker?
 
> Anyhow, basically, you can have many different "ticks" or pulses,
> or updates or whatever you want to call them.

Again, not entirely sure I'm understanding you correctly, but I
think this is how we do it. When the code is started (or hot
loaded), a bunch of 'tasks' are initialized (a couple hundred
actually). You specify, in a task, how many centiseconds from call
time it should first execute, and then how often after that it
should execute. So, for example:

  game_task (0, "atmospheric_messages", 20000, 20000, 0);
  game_task (0, "grove_dampen", 501, 498, 0);
  game_task (0, "shivering", 463, 463, 0);
  game_task (0, "drowning", 200, 200, 0);

There's one task that handles mob combat, one that handles
non-combat mob-ai, one that handles player racial regeneration, one
that handles regeneration from sleeping, etc etc. There's some
overhead for all the lists no doubt, but we've got over 6000 active
mobiles, and about 200 players currently online, and the code is
still spending 64% of its time just sitting there waiting for player
input.

So, like you say, it can easily be done without a big CPU hit, as
long as you make sure you're not doing intensive things every
quarter second or whatnot.

--matt

_______________________________________________
MUD-Dev mailing list
MUD-Dev at kanga.nu
https://www.kanga.nu/lists/listinfo/mud-dev



More information about the mud-dev-archive mailing list