Re: [ADMIN-CODE] Simple Distance code question

From: Patrick Dughi (dughi@imaxx.net)
Date: 05/09/00


>     Lets keep it simple firstly. Lets say each room is the same size. How
> can i find all the rooms in a 10 square radius. This means it's like a
> circle. 10 rooms north, south, east and west also mean that the furthest
> room to the North East would be north 7 and across 7, say . mapping that
> maps a *rough* ascii circle.
>     This assumes all rooms are mapped out, next to each other, etc..
>     But what happens if rooms link back to themselves, like a MAZE effect?

        You mean, like track does?  Just use a BFS, go ahead. Set the a
mark, leave it there.  Set your max hops for 10.  In the end, you'll have
a list of all rooms reachable by any means with a max range of 10.  Even
if you link to yourself, that's still just saying you're looking for all
rooms from your starting room with a range = range - 1.  No big deal here.
        Now, if you're trying to display a map of an area, and you're not
using strict 2-d or 3-d systems, you probably want to first figure out how
you're going to display an arbitrairyly dimensioned area in a useful
manner.  Personally, I can't see how you'd map a set of x nodes, each with
x paths - 1 per node + 1 to themselves - in a real space.  Of course, this
may not be what you're trying to do.  I just can't think of a good reason
to include the phrase "ascii circle" unless you want someone to visually
examine it like a circle (as opposed to an explosion sort of thing, which
would just be a 'range').  Perhaps I'm wrong, but if not, try restricting
your zones to a 3d system and you should be able to get away with it.

>
>     What about each room determining the effect of the distance remaining ?
> Eg. A underground room might double the current remaining distance, but if
> (recursively along the depth thru), it finds a room that is forest, the
> distance now is reduced, say. In effect, the distance is now possibly not
> circular (if you map it from above on a grid map), but each child from the
> starting room (node) may differ in length.

        This isn't hard.  You have 'weighted' paths.  Set your 'range' to
_x_ where _x_ is some arbitrairy value.  Now, take each path that you're
going to test and assign a weight to it based on it's end point.  Make
normal rooms .1 * x, and underground .2*x or something.  Start out with
_x_ range points and subtract the value/weight for each you pass through.
This is all elementary graph theory stuff, you should grab a book on it.

                                                PjD


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 04/10/01 PDT