File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,14 @@ function BiAStarFinder(opt) {
3535 }
3636 }
3737 }
38+
39+ //When diagonal movement is allowed the manhattan heuristic is not admissible
40+ //It should be octile instead
41+ if ( this . diagonalMovement === DiagonalMovement . Never ) {
42+ this . heuristic = opt . heuristic || Heuristic . manhattan ;
43+ } else {
44+ this . heuristic = opt . heuristic || Heuristic . octile ;
45+ }
3846}
3947
4048/**
Original file line number Diff line number Diff line change @@ -50,6 +50,14 @@ function IDAStarFinder(opt) {
5050 }
5151 }
5252 }
53+
54+ //When diagonal movement is allowed the manhattan heuristic is not admissible
55+ //It should be octile instead
56+ if ( this . diagonalMovement === DiagonalMovement . Never ) {
57+ this . heuristic = opt . heuristic || Heuristic . manhattan ;
58+ } else {
59+ this . heuristic = opt . heuristic || Heuristic . octile ;
60+ }
5361}
5462
5563/**
You can’t perform that action at this time.
0 commit comments