Search code examples
algorithmpointpath-findinga-star

Pathfinding : Jump Point Search - Straight Moves vs Diagonal Moves


Planning working on a 2D RTS, I tried to learn how Astar works. Indeed, I found articles explaining how Astar could be optimized coupling it with binary heaps, and algorithms taking advantages of Path symmetry, like Jump Poin Search algorithm. I tried to implement Jump Point Search, and it runs fine. I even made some benchmarks tests with maps from MovingAI.

Yet there is a problem. Everything runs fine when diagonal moves are allowed.When disabled, no path is returned...

It may be linked to the way I implementd it, then I'm all asking...In general, how would you oblige the algorithm (JPS) to search for path involving only straight moves (not diagonals moves) to reach a goal?


Solution

  • Jump point search NEEDS diagonals enabled to work. In state algorithm is in, this is one of its limitations. Also, you wont be able to make your terrain distinguishable (mud = penalty to movement, etc.) since this would destroy symmetries. I suggest you stick to A* and try to gain performance by terrain presentation (mesh, waypoints). Or maybe check HPA*.