src/map-node.js
/**
* @license
* pathfinding-visualiser <http://github.com/Tyriar/pathfinding-visualiser>
* Copyright 2014 Daniel Imms <http://www.growingwiththeweb.com>
* Released under the MIT license <http://github.com/Tyriar/pathfinding-visualiser/blob/master/LICENSE>
*/
(function (root, factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
define([], factory);
} else if (typeof exports === 'object') {
module.exports = factory();
}
}(this, function () {
'use strict';
function MapNode(x, y, parent, cost) {
this.x = x;
this.y = y;
this.g = 0;
this.f = 0;
this.parent = parent;
if (parent) {
this.g = parent.g + cost;
}
}
MapNode.prototype.equals = function (other) {
return this.x === other.x && this.y === other.y;
};
MapNode.prototype.getHashKey = function () {
return this.x + ',' + this.y;
};
return MapNode;
}));