Skip to content

Commit 94ff4ce

Browse files
committed
Rename GridNode .type property to .weight
1 parent 0c46ca5 commit 94ff4ce

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

astar.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,29 +231,29 @@ Graph.prototype.toString = function() {
231231
rowDebug = "";
232232
row = nodes[x];
233233
for (y = 0, l = row.length; y < l; y++) {
234-
rowDebug += row[y].type + " ";
234+
rowDebug += row[y].weight + " ";
235235
}
236236
graphString = graphString + rowDebug + "\n";
237237
}
238238
return graphString;
239239
};
240240

241-
function GridNode(x, y, type) {
241+
function GridNode(x, y, weight) {
242242
this.x = x;
243243
this.y = y;
244-
this.type = type;
244+
this.weight = weight;
245245
}
246246

247247
GridNode.prototype.toString = function() {
248248
return "[" + this.x + " " + this.y + "]";
249249
};
250250

251251
GridNode.prototype.getCost = function() {
252-
return this.type;
252+
return this.weight;
253253
};
254254

255255
GridNode.prototype.isWall = function() {
256-
return this.type === 0;
256+
return this.weight === 0;
257257
};
258258

259259
function BinaryHeap(scoreFunction){

test/tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ test( "GPS Pathfinding", function() {
166166
this.longRad = this.lng * Math.PI / 180;
167167
this.latRad = this.lat * Math.PI / 180;
168168
}
169-
CityNode.prototype.type = 1;
169+
CityNode.prototype.weight = 1;
170170
CityNode.prototype.toString = function() {
171171
return "[" + this.name + " (" + this.lat + ", " + this.lng + ")]";
172172
};

0 commit comments

Comments
 (0)