Re: Finding the Nearest Person <3.0.32.19980305190151.0068bf40@gatekeep.net>

From: Jeremy Elson (jelson@CIRCLEMUD.ORG)
Date: 03/05/98


Wesley Fonvergne writes:
>        I was looking through the find_first_step function, which track is bas
>ed
>off of, which determines the direction a player must next go to find
>someone. Thinking this over, would it be possible to determine the entire
>set of steps needed to a player, and then find that for every person in a
>zone, and then compare how many there were to find which player is closest?
>Is this possible to do, in C code, or would it cause too much processing to
>have every MOB doing this at one time? Thanks for any help! :)

It can be done very efficiently in linear time with the number of
rooms in the world.  The find_first_step function actually performs a
breadth-first-search expanding outward from the player until it hits
the MOB.  If you change it slightly, you can have it instead expand
outward starting from the MOB until it first hits a room that has a
player.  Very easy, probably a 10 minute hack if you know how BFS
works.

-Jeremy


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



This archive was generated by hypermail 2b30 : 12/15/00 PST