@@ -56,13 +56,11 @@ var astar = {
56
56
astar . init ( graph ) ;
57
57
58
58
options = options || { } ;
59
- var heuristic = options . heuristic || astar . heuristics . manhattan ;
60
- var closest = options . closest || false ;
59
+ var heuristic = options . heuristic || astar . heuristics . manhattan ,
60
+ closest = options . closest || false ;
61
61
62
- var openHeap = astar . heap ( ) ;
63
-
64
- // set the start node to be the closest if required
65
- var closestNode = start ;
62
+ var openHeap = astar . heap ( ) ,
63
+ closestNode = start ; // set the start node to be the closest if required
66
64
67
65
start . h = heuristic ( start , end ) ;
68
66
@@ -84,7 +82,7 @@ var astar = {
84
82
// Find all neighbors for the current node.
85
83
var neighbors = graph . neighbors ( currentNode ) ;
86
84
87
- for ( var i = 0 , il = neighbors . length ; i < il ; i ++ ) {
85
+ for ( var i = 0 , il = neighbors . length ; i < il ; ++ i ) {
88
86
var neighbor = neighbors [ i ] ;
89
87
90
88
if ( neighbor . closed || neighbor . isWall ( ) ) {
@@ -94,8 +92,8 @@ var astar = {
94
92
95
93
// The g score is the shortest distance from start to current node.
96
94
// We need to check if the path we have arrived at this neighbor is the shortest one we have seen yet.
97
- var gScore = currentNode . g + neighbor . getCost ( currentNode ) ;
98
- var beenVisited = neighbor . visited ;
95
+ var gScore = currentNode . g + neighbor . getCost ( currentNode ) ,
96
+ beenVisited = neighbor . visited ;
99
97
100
98
if ( ! beenVisited || gScore < neighbor . g ) {
101
99
@@ -322,7 +320,6 @@ BinaryHeap.prototype = {
322
320
// Update 'n' to continue at the new position.
323
321
n = parentN ;
324
322
}
325
-
326
323
// Found a parent that is less, no need to sink any further.
327
324
else {
328
325
break ;
@@ -337,11 +334,11 @@ BinaryHeap.prototype = {
337
334
338
335
while ( true ) {
339
336
// Compute the indices of the child elements.
340
- var child2N = ( n + 1 ) << 1 , child1N = child2N - 1 ;
341
- // This is used to store the new position of the element,
342
- // if any.
343
- var swap = null ;
344
- var child1Score ;
337
+ var child2N = ( n + 1 ) << 1 ,
338
+ child1N = child2N - 1 ;
339
+ // This is used to store the new position of the element, if any.
340
+ var swap = null ,
341
+ child1Score ;
345
342
// If the first child exists (is inside the array)...
346
343
if ( child1N < length ) {
347
344
// Look it up and compute its score.
@@ -369,7 +366,6 @@ BinaryHeap.prototype = {
369
366
this . content [ swap ] = element ;
370
367
n = swap ;
371
368
}
372
-
373
369
// Otherwise, we are done.
374
370
else {
375
371
break ;
0 commit comments