File tree Expand file tree Collapse file tree 1 file changed +7
-11
lines changed Expand file tree Collapse file tree 1 file changed +7
-11
lines changed Original file line number Diff line number Diff line change @@ -166,25 +166,21 @@ var astar = {
166
166
* @param {bool } [diagonal] Specify whether diagonal moves are allowed
167
167
*/
168
168
function Graph ( gridIn , diagonal ) {
169
- var nodes = [ ] ;
169
+ this . nodes = [ ] ;
170
+ this . diagonal = ! ! diagonal ; // Optionally find diagonal neighbors as well (false by default).
170
171
171
172
if ( gridIn ) {
172
- var grid = [ ] ,
173
- node ;
173
+ this . grid = [ ] ;
174
174
for ( var x = 0 ; x < gridIn . length ; x ++ ) {
175
- grid [ x ] = [ ] ;
175
+ this . grid [ x ] = [ ] ;
176
176
177
177
for ( var y = 0 , row = gridIn [ x ] ; y < row . length ; y ++ ) {
178
- node = new GraphNode ( x , y , row [ y ] ) ;
179
- grid [ x ] [ y ] = node ;
180
- nodes . push ( node ) ;
178
+ var node = new GraphNode ( x , y , row [ y ] ) ;
179
+ this . grid [ x ] [ y ] = node ;
180
+ this . nodes . push ( node ) ;
181
181
}
182
182
}
183
- this . grid = grid ;
184
183
}
185
-
186
- this . nodes = nodes ;
187
- this . diagonal = ! ! diagonal ; // Optionally find diagonal neighbors as well (false by default).
188
184
}
189
185
190
186
Graph . prototype . add = function ( node ) {
You can’t perform that action at this time.
0 commit comments