View unanswered posts | View active topics It is currently Fri Mar 29, 2024 7:54 am



Reply to topic  [ 5 posts ] 
 getNearestWarps 
Author Message
Boo! inc.

Joined: Fri Jan 04, 2002 3:00 am
Posts: 221
Location: Canada
Unread post getNearestWarps
has anyone ever had problems with getNearestWarps not sorting the data by distance?

I have found that sectors with one ways next to a sector you are getting nearest warps of end up giving warps all over the map. it starts with 1 out, but then can jump to 25 next warp, then 2 for a bit then 27. it makes relying on the distance sort tough when you make a near fig finder that fires out 5 near fighters.

here is just a snippet of data spit out of the nearest warps array

Code:
Nearest  sector to 2707:

Sector: 2707 hops:-1
Sector: 4 hops:1
Sector: 2042 hops:1
Sector: 5496 hops:1
Sector: 6872 hops:1
Sector: 16706 hops:1
Sector: 18394 hops:25
Sector: 1 hops:2
Sector: 3 hops:2
Sector: 5 hops:2
Sector: 1462 hops:2
Sector: 2049 hops:2
Sector: 6979 hops:2
Sector: 1879 hops:2
Sector: 6476 hops:2
Sector: 15536 hops:2
Sector: 199 hops:2
Sector: 19998 hops:2
Sector: 3243 hops:24
Sector: 6265 hops:24
Sector: 18420 hops:24
Sector: 2 hops:3


you will see it starts out -1, then does a bunch at 1 hop from that sector to 2707. then all of a sudden there is a 25. now that sector is next to 2707, but its a one way out of 2707. so in reality getnearestwarps seems to give you the nearest warp out of a sector instead of nearest warp into a sector. the hop count is a course plot from that sector to 2707.


Fri Mar 07, 2014 1:01 am
Profile
Commander
User avatar

Joined: Tue Oct 07, 2003 2:00 am
Posts: 1131
Location: Augusta, GA
Unread post Re: getNearestWarps
Hmm, I'm not sure I understand. If you execute 'getNearestWarps $warps 2707', then the $warps array will be sorted based on the distance from 2707.

Of course, TWX's ability to accurately plot the warps is dependent on the warps it knows about. I expect that if you're seeing incorrect results, that it's the result of limited warp data in the TWX database.

Please let me know if you find otherwise, or if there's something more specific I can troubleshoot with you.

_________________
Claim to Fame: only guy to ever crack the TW haggle algorithm, and fig/shield/hold price formula, twice.


Sat Mar 15, 2014 2:32 pm
Profile WWW
Commander
User avatar

Joined: Mon Oct 29, 2001 3:00 am
Posts: 1096
Location: Tucson, AZ
Unread post Re: getNearestWarps
I think what he's getting at is that it's sorted by the distance from the origin, but it displays the distance to the origin. If this isn't a bug, it may be a misfeature. In the example shown, we can't tell whether sector 18394 is 1 or 2 hops from the origin.

Quote:
Sector: 16706 hops:1
Sector: 18394 hops:25
Sector: 1 hops:2

_________________
Suddenly you're Busted!


Sat Mar 15, 2014 5:22 pm
Profile WWW
Boo! inc.

Joined: Fri Jan 04, 2002 3:00 am
Posts: 221
Location: Canada
Unread post Re: getNearestWarps
you know how you have warps in. and warps out. and they are not always the same? I believe that get nearest warps does warps out. so if i use that to get the nearest fighter, it may not be correct as in the example of 18394 because 18394 is a one way out of 2707. which is 25 hops to 2707 from 18394.

maybe it should be renamed getnearestwarps out. and then make a getnearestwarps in command?

but getnearestwarps doesn't know, it assumes it is the closest distance because it is adjacent to 2707.


Sat Mar 15, 2014 10:24 pm
Profile
Commander
User avatar

Joined: Tue Oct 07, 2003 2:00 am
Posts: 1131
Location: Augusta, GA
Unread post Re: getNearestWarps
Mongoose wrote:
I think what he's getting at is that it's sorted by the distance from the origin, but it displays the distance to the origin. If this isn't a bug, it may be a misfeature.

The result of the getNearestWarps command is simply a sorted list. Nothing is displayed, and no distances are indicated.

Tweety wrote:
so in reality getnearestwarps seems to give you the nearest warp out of a sector instead of nearest warp into a sector.

Correct. In TWX (and TW in general I believe), the term WARPS is always used to indicate warps out. I'll take that a step further and say that warps (meaning warps out) are known, and warps in are calculated or deduced. So I assert that the term WARPS is unambiguous, and always means warps out. I regret if this has caused confusion, but the command's name is consistent with other TWX command names involving warps and warps in.

getNearestWarps simply performs a breadth-first search with the specified origin, and returns the sorted results in an array. It is identical to the following code, where $origin is the origin, and $queue is the sorted resultant array:
Code:
setArray $checked SECTORS
setVar $checked[$origin] TRUE
setVar $top 1
setVar $bottom 1
setArray $queue SECTORS
setVar $queue[1] $origin
while ($bottom <= $top)
   setvar $focus $queue[$bottom]
   setVar $i 1
   while ($i <= SECTOR.WARPCOUNT[$focus])
      setVar $adjacent SECTOR.WARPS[$focus][$i]
      if ($checked[$adjacent] = FALSE)
         add $top 1
         setVar $queue[$top] $adjacent
         setVar $checked[$adjacent] TRUE
      end
      add $i 1
   end
   add $bottom 1
end
setArray $checked 0

I created getNearestWarps because I found that I used the above BFS code repeatedly. I wanted to speed it up and simplify it's usage, and thus getNearestWarps was born. There is a clear need for getNearestWarpsIn, but it hasn't made it into the TWX code yet. Until such a time, the BFS code above requires minor modification to return results based on WarpsIn, and is as efficient as it can be without being a native command. I'd be happy to post the WarpsIn version though.

_________________
Claim to Fame: only guy to ever crack the TW haggle algorithm, and fig/shield/hold price formula, twice.


Sun Mar 16, 2014 9:46 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


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 post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware.