Search code examples
javascriptnode.jspath-finding

Possible To PathFind a 1000x1000 Grid Map NodeJS?


I am making a game with a Node server which uses pathfinding for the enemies. I was using a 100x100 grid map and I did not see any slowdowns on performance, but when I raised the size to 1000x1000, each time a path is generated there is now a 1 second delay on the server.

Currently I am using PathFindingjs with A* path finding. Is there a better path finding library or path finding algorithm that will allow the use of a 1000x1000 grid without a delay, or am I out of luck?

Any help is appreciated, thank you.


Solution

  • What do you mean by "delay"? Like, it took longer to process a larger grid when nothing else was happening? Or, the processing "froze" while the path was calculated and then continued on?

    Taking longer to process is natural for a large processing space. More cells is more compute power needed. There's no way around that, other than other CPU cores or some sort of processing service. That might be an answer to your question right there.

    Nodejs is a single-threaded system, so all that processing will hang up the other actions that are going on. There might be ways to run chunks of the path processing that doesn't noticeably affect other things - unsure how the lib is built. Or chunk the grid to more manageable segments for the pathing algorithm (would 4 500x500 grids be almost the same?, that kind of thing). Or have two different servers on the same machine - pathing and other, and segment your requests.