BWTA::getGroundDistance2(tilePos1, tilePos2) always returns -1
BWTA::getGroundDistance() seems to work fine. It has been like this for maybe a year now... Am I missing something when using BWTA::getGroundDistance2()?
Comments (16)
-
repo owner -
reporter oh, I wasn't aware. I will try again
-
reporter Following your advice, I've got it to work. Thanks! :) But now it seems like the method sometimes crashes, e.g. for tilePos1 {x=28 y=116 }
tilePos2 {x=69 y=122 } on the map Destination.Additionally, I don't understand why getGroundDistance(), i.e. the original method returns -1 for the following distances: + tilePos1 {x=32 y=97 } + tilePos2 {x=48 y=64 } again on the same map. Both positions are definitely connected and seem walkable. Any clue?
-
reporter @auriarte, any ideas?
-
repo owner I will try to look at it tomorrow ;)
-
reporter Thanks, @auriarte
-
reporter hey, @auriarte! Any progress? :)
-
repo owner tilePos(28,116) is a non walkable tile (only a few pixels are walkable, so it is considered as a non walkable tile), hence the result for both functions getGroundDistance() and getGroundDistance2() is "correct".
For the distance between (32,97) and (48,64) I have correct results on both functions
- getGroundDistance(): 1344
- getGroundDistance2(): 1523
-
repo owner Uops, btw I fixed to no to crash when the tile doesn't belong to a region (ie. is non walkable), so now tilePos(28,116) shouldn't crash ;)
-
repo owner - changed status to resolved
-
reporter @auriarte Thanks for taking the time to investigate the issue! :)
The crash fix of getGroundDistance2() seems to work!
For the distance between (32,97) and (48,64) I get the same result with getGroundDistance2(): 1523, but getGroundDistance() still returns -1 and I can't figure out why (I can't link the Debug version with my bot for some reason...).
BWTA.lib is compiled in Release with all optimizations on. Additionally, I am attaching the map in question in case we're using different versions...
-
repo owner You can try a couple of things:
- Re-analyze the map (just to be sure)
- Run the OfflineTester project to see if you still have the error in the test environment.
- If you still have the error run the OfflineTester in Debug mode
- If not... try to link your bot to BWTA Debug (BWTAd.lib). What is exactly your error?
-
reporter You won't believe how stupid the bug was!!! Lol.
After debugging lasting more than half a day, I finally found out that the root cause was a neutral bear in the middle of the map at the start of the game which causes some Build Tiles to be marked as unwalkable. Since they're unwalkable, getGroundDistance() returns -1. My fix (https://bitbucket.org/auriarte/bwta2/commits/9405e154a548cd799436f0fb9f62b93b05295c62) is to only consider non-movable neutral units in such cases.
Now, the next question is whether any neutral units (even the non-movable) should mark a position unwalkable. What do you think? I guess the answer is no?
-
repo owner What? I hate neutral units!!!
Only the undestroyable non-movable neutral units should mark a position as unwalkable (we are already doing that). Uff, now that I see this is "old" code, I should refactor to C++11 all the library :P
Thanks for catching the bug!!!
-
reporter That's a good point about the destructibility. I've added that condition as well, so now, only units that are both indestructible and non-movable are considered
-
reporter Wrt ti C++11, BWTA also compiles with VC140 (VS 2015), so most of C++14 can be used, too
- Log in to comment
Did you call buildChokeNodes() after analyzing the map? It is needed to generate the cache data.