PathFinding.js icon indicating copy to clipboard operation
PathFinding.js copied to clipboard

Who can provide a C ++ version of the code?

Open yu2014ol opened this issue 5 years ago • 5 comments

My code has encountered performance problems. I tried many times, and it is difficult to achieve the performance of the repository's code, so I think it may need to be rewritten. If you have a mature solution for me, I will be grateful.

yu2014ol avatar Apr 10 '20 14:04 yu2014ol

Just search for "C++ A*", an implementation of Breadth First Search, Djikstra and A* can be found here: https://www.redblobgames.com/pathfinding/a-star/implementation.html#cplusplus Also take a look at optimizations there: https://www.redblobgames.com/pathfinding/a-star/implementation.html#optimizations

brean avatar Apr 10 '20 15:04 brean

Just search for "C++ A*", an implementation of Breadth First Search, Djikstra and A* can be found here: https://www.redblobgames.com/pathfinding/a-star/implementation.html#cplusplus Also take a look at optimizations there: https://www.redblobgames.com/pathfinding/a-star/implementation.html#optimizations

Wow, thank you. My own code is based on redgames. I have tried some of these optimizations, but it has not worked very well. The author said on the webpage that it is not production code and he didn't run the benchmarks. I found that the operation related to the hash is the most time-consuming through testing. At the same time, I doubt whether it is because the close set is not set. I am still trying to improve, but I am not sure if it needs to be rewritten according to Pathfinding.

yu2014ol avatar Apr 11 '20 04:04 yu2014ol

The difference of that code to this is that Pathfinding.js stores everything in node objects, so it can execute code on the node without calculating a hash to get the node all the time, maybe that helps you. For further help I think I need your code and your grid-data.

brean avatar Apr 11 '20 10:04 brean

The difference of that code to this is that Pathfinding.js stores everything in node objects, so it can execute code on the node without calculating a hash to get the node all the time, maybe that helps you. For further help I think I need your code and your grid-data.

I thought about this problem before. So now the only way to improve the efficiency of the code is to refactor. This is painful, but may have to be done.

yu2014ol avatar Apr 11 '20 13:04 yu2014ol

I have a new discovery. When the C ++ version is set to -O3 optimization, the code runs quickly, close to the speed of Pathfinding.js. But I am not sure if it is always so fast.

yu2014ol avatar Apr 11 '20 14:04 yu2014ol