Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Jim Vance
Beginner


Joined: 07 Dec 2006
Posts: 16

PostPosted: Thu Jun 03, 2010 12:55 am   

Mapper Scripting Riddle
 
I am looking for a simple solution to an issue that I recently dreamed up. This issue involves the Automapper and deciding the fastest routes.

(Some background)
I love using the mapper, but the #WALK command normally parses a huge string of commands that creates a bit of screen lag. In order to overcome the lag, I have started scripting aliased "paths" from known points within specific areas to specific destinations. (I use the term "paths" loosely, because I am using an in-game feature for traveling, not the #PATH command.) This approach is much better, eliminating most of the parsing lag. However, I recently ran into a bit of a quandary due to what might be called "multiple access points". (diagram supplied below)

Code:

            [A]
           .   .     pA
         .       .
       .           .
     .               .
  [x]                  [1]
     .               .
       .           .
         .       .
           .   .     pC
            [C]



Starting at some variable point [1], there are two points ([A], [C]) to access the area where the destination [x] resides. (In the MUD I play, [A] and [C] are bridges.) If there was a single access point, I would run a #WALK command to that point, followed by an aliased path to the destination. So, in a nutshell, how do I find which point is closer to use #WALK?

Here's my (clumsy) solution:

1. Get the current roomnumber
2. Get distance of path A (currently using %pathfrom, %pathexpand, and %numitems - is there a better way to count exits between two points?)
3. Get distance of path C
4. Compare distances, choose shortest, and #WALK

Anyone want to help me out? Any help would be appreciated. (This isn't ruining my experience, it's just a little coding riddle.)

Thanks in advance.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Thu Jun 03, 2010 2:51 am   
 
If you are wanting to compare walk lengths between A1-Z, A2-Z, and so on, all you need to do is use %pathfrom() using the vnums for the A rooms. CMud is already calculating the shortest path between each point, so all that is left is to compare the results.
_________________
EDIT: I didn't like my old signature
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Thu Jun 03, 2010 1:41 pm   
 
Vance, your method is basically the easiest way to determine whether A or C is closer. I've used a similar method for calculating distances myself. However, that does not tell you how far A or C is from x. If you want to know the total shortest distance, you'd need to deal with that length as well.

What Matt is suggesting is doing a %pathfrom between x and 1, then seeing whether it goes through A or C.

I'm not sure what you mean by "#WALK command normally parses a huge string of commands that creates a bit of screen lag." If you use Safe or Slow walk mode, it shouldn't send all the commands at once.
Reply with quote
Jim Vance
Beginner


Joined: 07 Dec 2006
Posts: 16

PostPosted: Sat Jun 05, 2010 3:53 am   
 
Thanks for the feedback.

So, how would I use %pathfrom to determine whether the shortest path from [1] to [x] goes through [A] or [C]? That seems like a much better solution to what I am trying to do.

@Rahab: I am using the Fast walk mode, and it does create a bit of lag at first. Then the buffer speeds ahead and I get a bit of "visual whiplash". :)
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Sat Jun 05, 2010 1:37 pm   
 
With Fast walk mode, I could see that happening, which is why I suggested Safe or Slow walk. Is there a particular reason you prefer Fast walk mode if it causes this problem?

As for how to do that...hm. I guess I would use %pathexpand(%pathfrom(1,x)) to find the correct path, and %pathexpand(%pathfrom(1,A)) and %pathexpand(1,C)) to find the bridge paths. Then I would compare the first path, element by element, to the second two paths until I could eliminate one of them.

Matt might have another solution.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net