>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. Another way, one someone pointed out to me, is to make a 'blot' command. What the blot will do, is find all rooms within a certain range, and keep the list of rooms. The idea of this is, you can do a check for 1 room range, then 2 rooms, 3 rooms, etc. A blot works like this: struct room_list blot(int room, int range, int max_range, struct room_list *list) { add room to list set BFS_MARK to room if (range >= max_range) return list loop through exits if exit is legal (checking for BFS_MARK too) blot(exit->to_room, (range + 1), max_range, list) end loop return list } In case you can't guess, this code is just the skeleton. YOU have to fill in the blanks and do the actual code. Othere then that, it is pretty simple. The idea is, you send in this, and send back a list of all rooms, including ranges. Then, you go through rooms, and see if there are any characters (or mobs) in the rooms listed. Then, you can do what you want. I would suggest that setting the HUNTING on the mob to the character you found, and then letting the hunt code do the hard work. :) "One hundred years from now, none of this will matter because you and I will be dead -- unless the Grim Reaper has switched his record-keeping to a Windows 95-based system, in which case we all might live forever. " -- Associated Press +------------------------------------------------------------+ | 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