View Single Post
Old 04-04-2003, 10:47 AM   #9
KaVir
Legend
 
KaVir's Avatar
 
Join Date: Apr 2002
Name: Richard
Home MUD: God Wars II
Posts: 2,052
KaVir will become famous soon enoughKaVir will become famous soon enough
I think you mean 2 bits per player pair. Introducing yourself to someone else should not automatically grant you the knowledge of who they are as well.

(1000*1000)-1000 = 999000 bits = ~122K for 1000 players.

So each player is allocated a "free" slot number when they log on. To see if you know someone, do a lookup based on your slot number at that of the person you're looking at.

Instead of blanking the bits upon logging out, I would suggest doing it when you log in. The mud could then use an array of (in this case) 1000 unique 32 bit IDs, which are compared against a (true) unique character ID. When a character connects, the mud could first check the list to see if that character's information is still there - and if so, just assign them that slot number again. To help cut down on slots from being quickly overwritten, the "search for next free slot" should begin at the slot AFTER the last person to have quit, and should try to use the as-yet-unused slots first if possible. This is important, because using your approach, loading is going to be hard work...

The real problem comes when there isn't any valid slot information. First of all you'd have to load up the list of who they know (from a separate file), then you'd have to work your way through every active slot in the list. For each slot, you'd have to (1) check that person's ID against the newly loaded list and update the new slot if necessary, and (2) load up the list of who THAT person knows, check if they know the loading character, and update their slot if necessary.
KaVir is offline   Reply With Quote