qiao / PathFinding.js

A comprehensive path-finding library for grid based games
http://qiao.github.io/PathFinding.js/visual/
8.47k stars 1.33k forks source link

Diagonal pathfinding can't find a path through a mostly-walled off vertex #157

Open tones31 opened 6 years ago

tones31 commented 6 years ago

I didn't know how to word the question, but with this image its easy to understand: I think there is an inconsistency here when using diagonal path finding. If you wall off a vertex other than two open walls, the pathfinding will work and even use diagonal pathing. If however you leave only one open wall, the pathfinding will no longer work.

My expected result for these two examples would be the same. Is there some option to be set that allows going through walls diagonally? See pic:

image

tones31 commented 6 years ago

Hmm, maybe the visualizer is old code? Because diagonalMovement : PF.DiagonalMovement.Always actually allows this...

brean commented 6 years ago

Yes, the visual representation uses an build that is actually a few days older than the last change to DiagonalMovement in Pathfinding.js and there is a commit message for the DiagonalMovement-change, so without cloning and rebuilding the code I assume you are right.

brean commented 6 years ago

I cloned the code and tested it. The visual editor calls the AStarFinder with "diagonalMovement" set to undefined, "allowDiagonal" to 1 and "dontCrosscorners" to false, so the logic here sets diagonalMovement to "IfAtMostOneObstacle" (3) instead of "Always" (1). I suggest it should be changed in the visual editor to be a drop-down instead of checkboxes so the user set diagonalMovement and we should remove "allowDiagonal" and "dontCrossCorners ", because they are marked as deprecated.

tones31 commented 6 years ago

Yes - also in the main github readme, both of those deprecated properties are used.