[MUD-Dev] Naming and Directories?

Caliban Tiresias Darklock caliban at darklock.com
Sat Mar 13 15:03:50 New Zealand Daylight Time 1999


On 11:48 PM 3/13/99 +0000, I personally witnessed Mik Clarke jumping up to say:
>
>Given a task of sending a message to a specific player, when that player 
>could be
>located anywhere within the mud, how do you propose to do it faster than by 
>running
>the list of all connected players?  Sure, a binary index by name might help, 
>but I
>suspect you'd have trouble seeing the saving...

Given a name which does not change and is guaranteed unique, such as the
name of a MUD player (most MUDs don't let you change your name, although
most MUSHes do), you could assign identifying numbers *based* on that name. 

Example: Bob connects. Bob's name is CRC-16'd to get his player number.
That player number is loaded. (Collisions on new player creation are
resolved by telling Bob to choose another name.) The existing list of
players is examined, through binary search, to insert Bob's number in the
sorted list. Someone does a "tell" to Bob. Bob is CRC'd, the list is binary
searched, and Bob is located. Bob gets his tell. Bob disconnects, and is
removed from the list. The other player does another tell, the list is
searched again, and determines that Bob is not there. The player is told
that Bob isn't online.

Savings? Only when the CRC is less time consuming than text-comparison and
the binary search is faster than a linear search. Since text comparisons
are slow and table-based CRCs are fast, the former is often true; since
more than five players saves you compares on a binary search, the latter is
often true. (However, it may be just as fast if not faster to sort the list
of players alphabetically.) 

Unfortunately, many of us are trying to get away from the
one-player-one-name thing, which doesn't lend itself well to this approach. ;)

-----
| Caliban Tiresias Darklock            caliban at darklock.com 
| Darklock Communications          http://www.darklock.com/ 
| U L T I M A T E   U N I V E R S E   I S   N O T   D E A D 
| 774577496C6C6E457645727355626D4974H       -=CABAL::3146=- 


_______________________________________________
MUD-Dev maillist  -  MUD-Dev at kanga.nu
http://www.kanga.nu/lists/listinfo/mud-dev




More information about the MUD-Dev mailing list