Top Mud Sites Forum Return to TopMudSites.com
Go Back   Top Mud Sites Forum > Mud Development and Administration > MUD Coding
Click here to Register

Reply
 
Thread Tools
Old 05-21-2003, 01:35 AM   #1
karlan
Member
 
Join Date: Apr 2002
Location: Brisbane Australia
Posts: 74
karlan is on a distinguished road
Unhappy

At the moment I have some very vindictive mobs, that not only remember a player but will also activley seek them out, unfortunately the system used to choose their next move is almost guaranteed to lead them to the target. Now I want to change this to use the traking skill (builders can asign skills to mobs by specifying a range (or just a min as a fixed value, but that is discouraged) to decide the next step, this frees me from having to use any graphing algorithms, and seems more realistic, if a player can hide their tracks well enough, or lay a set of false tracks that are good enough then the mob should be thrown off. But, I am in the middle of rewriting how tracks and tracking are handled, and I am back on the issue of CPU vs Memory usage, I would like to have the tack information stored in a list (prob really an array *shrug* ) associated with each exit of each room, but if you have a struct for the track information (who, ttl, ifReal, amtHidden - all bytes would be good, since it puts the size of the struct on a 32bit word boundary), and an array of 8 of these on each of 10 exits (n, ne, e, se, s, sw, w, nw, u, d), you have   4 * 8 * 10 = 320 bytes of data, just on track information, for each room, and that is using the smallest amount of information I can (which would mean I couldn't have more than 255 players and mobs - unrealistic I know, just an example).

So, how do other people handle it? Do people use a complicated but hopefully more realistic method, or go for quick and simple. Also once you start adding in scents....
karlan is offline   Reply With Quote
Old 05-21-2003, 04:32 AM   #2
Tamsyn@zebedee.org
New Member
 
Join Date: Mar 2003
Posts: 23
Tamsyn@zebedee.org is on a distinguished road
In a word: Simple

Each of our rooms has 1 set of tracks, in 1 direction, at any time. I would think you only need more if player's tracks are likely to cross.

If you need more, then I would assign a disappearance time to each set of tracks in a room, so you'd free memory as old tracks disappeared, and each time a new player entered/left the room add a new track description to the list.
Tamsyn@zebedee.org is offline   Reply With Quote
Old 05-21-2003, 04:38 AM   #3
karlan
Member
 
Join Date: Apr 2002
Location: Brisbane Australia
Posts: 74
karlan is on a distinguished road
Any tracks I use will have a ttl (Time To Live), it's more an issue of how much to keep, say 6 sets of tracks for a room, or 4 for each exit (possibly 40 per room)..
karlan is offline   Reply With Quote
Old 05-21-2003, 08:54 AM   #4
jornel
Member
 
Join Date: Sep 2002
Location: Canada
Posts: 73
jornel is on a distinguished road
If you're going the TTL route for your tracks,  you can save oodles of memory by only using dynamically assigned tracks as players move around your world.

Something like this (I don't remember the memory macro names off the top of my head, but you will).

[code]
void playerleft(player, room, direction)
{
struct track *p,*track,tracknext;

 /* first clean out expired or trampled over tracks */
 for(p=NULL,track=room->firsttrack;track;track=tracknext)
 {
    tracknext=track->next;
    if(track->dir = direction || ttl_expired(track))
    {/* these tracks should go */
       if(p)
         p->next=tracknext;
       else
         room->firsttrack=tracknext;
       STRFREE(track->playername);
       DISPOSE(track);
    }
    else
    {/* these tracks don't disappear yet.  keep them. */
      p=track;
    }
 }

 /* fill out new track struct for current player */
 track=ALLOCATE(struct track);
 track->dir = direction;
 track->playername = STRALLOC(player->name);
 track->ttl = make_ttl( TRACK_TTL );

/* add fresh tracks to room */
 track->next=room->firsttrack;
 room->firsttrack=track;
}

[/quote]

Example: Joe just left west.

We scan the list of current tracks in the room, looking for any that went out the west exit.  Dispose those since Joe would have trampled over them.  We also dispose any which have  expired TTL.

We allocate a new track structure.  Fill it out with whatever info you want, plus TTL

Finally add Joe's tracks to the room.  We are done.


This algorithm doesn't need a mostly empty 4*8*10 array per room, just a hook (firsttrack) to hang the first set of tracks in the room.

Rooms that don't get visited often may wind up with a lot of expired tracks that never get cleared unless someone visits the room.  

A nice low-CPU lazy way to clean these up costs you a single integer:  next_vnum_to_clean.

Once per update:

[code]
for(i=0;i<MAX_ROOMCLEANING_PER_UPDATE;i++)
{
if (next_vnum_to_clean IS a valid room number)
{
   scan list of all tracks in the room.
   dispose those that have expired TTL.
}
if(++next_vnum_to_clean>=MAX_ROOM_VNUM)
  next_vnum_to_clean = 0; /* or 1. it matters little */
}

[/quote]

This will guarantee you will not have tracks older than

oldest track age = ( MAX_ROOM_VNUM / MAX_ROOMCLEANING_PER_UPDATE ) * update_period

and it only costs the CPU checking at most MAX_ROOM_CLEANING_PER_UPDATE rooms per update.


Hope this helps.
jornel is offline   Reply With Quote
Old 05-21-2003, 09:26 AM   #5
karlan
Member
 
Join Date: Apr 2002
Location: Brisbane Australia
Posts: 74
karlan is on a distinguished road
The main thing is to have more than 1 set of tracks per exit, it is very rare for one person/animal to completely destroy a set of tracks, even if they have to follow almost the same path, at the moment I have a machine with a fair bit of memory but my CPU is old and slow P3 800 so I am leaning towards I slightly more memory intensive than cpu intensive model. Since rooms get a update every n cycles anyway I was looking at just updating all the tack information then (ugly I know, but linear advances through arrays can be quite fast as the cpu and MMu will start to cache ahead some of the entries), OR maybe having a global list of track information with ppointers into the the list from each room, so to display the info for a room only requires geting the node at the pointer from that room, display info, get next node, check room num, if required show that. and updates of all tracks ttl only requires a single pass through the list every n cycles. still undecided
karlan is offline   Reply With Quote
Old 05-21-2003, 09:59 AM   #6
OnyxFlame
Member
 
Join Date: Aug 2002
Posts: 153
OnyxFlame is on a distinguished road
Post

DISCLAIMER: I know nothing about code.

All you have to do then is when Joe goes west, have his passage degrade the tracks already going west, and if the tracks were already degraded far enough or have run out of time, his passage would destroy them entirely.

If your mud has sizes, you could make it so that large beings degrade tracks much faster than small beings. Of course, small beings would have tracks that were much harder to see too, considering they don't step on the ground with the same force.

You could maybe just do this with the ttl thing, or have the ttl and a difficulty rating on each set of tracks. If you just use ttl, when a person walks over a previously existing set of tracks, it would just decrease the time left on the old track's ttl, and if the time happens to expire in the process, the old tracks would be removed. If you use ttl and difficulty, the new set of tracks would increase the difficulty of seeing the old tracks, but not change the ttl of the old tracks. If you use the 2nd method, people would of course have many difficulties of existing tracks to use to practice their tracking skill. Or you could do the same thing only needing to store ttl, by having a set table of how hard certain ranges of ttl are to track. (This way, in areas where people leave little to no tracks, the tracks they do leave could just be set at a very short ttl and still be really hard for anyone to pick up.)

Does any of this make sense, or am I just babbling randomly?
OnyxFlame is offline   Reply With Quote
Reply


Thread Tools


Tracking/Hunting Mobs - Similar Threads
Thread Thread Starter Forum Replies Last Post
Data Tracking Trevalen MUD Administration 4 05-15-2006 01:37 PM
Hunting in Lusternia Estarra MUD Announcements 0 09-05-2005 09:28 PM
Hunting Parties/Barbarian camps... The Vorpal Tribble Advertising for Players 0 05-14-2004 05:37 PM
Expanded socket/IP/NIC tracking anyone? Terloch MUD Coding 7 02-11-2003 03:12 PM
Mobs Keljorian MUD Builders and Areas 3 05-31-2002 12:14 PM

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

All times are GMT -4. The time now is 10:08 PM.


Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Style based on a design by Essilor
Copyright Top Mud Sites.com 2014