View Single Post
Old 06-29-2012, 04:09 PM   #38
camlorn
Member
 
Join Date: Aug 2011
Posts: 144
camlorn is on a distinguished road
Re: Can MUDs implement range/distance?

Ok, so a few thoughts on this.

Firstly, godwars2 does this. Go look at it for a good example which is running still.

Secondly, there's a harder, but less processor intensive way of finding near objects. I forget what this is called--I'm not smart enough to have come up with it--and a lot of 3d engines use it:

The world is a quadrant forming the first node of a tree.
Divide the world into some number of quadrants--9 works well--and make them the next set of nodes in the tree.
Keep dividing until you get to the desired resolution.

To find an object in the same area as a player, you simply walk up the tree to the desired resolution and get the list from that. You can do that by finding all leaf nodes below the desired resolutional node (new term!), or you can sacrifice memory and store each object in all nodes containing it...so, the world node gets all objects.

If someone can remember what this is called, it'd be a help--I'm bad at explaining it.

Also, you can divide up the world into "regions" or "maps" or what-have-you, making the two lists in the o(p*n) algorithm smaller--p is the limit in each map and n the number of objects in that map. Should help anyway.
camlorn is offline   Reply With Quote