Skip to content

Commit

Permalink
Changed the heuristic of the A* algorithm to Manhattan.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrespagella committed Jul 22, 2011
1 parent c014bf5 commit 6b97da9
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions examples/astar.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,16 @@ aStar.prototype.checkDifference = function(src, dest) {
}

aStar.prototype.getDistance = function(src, dest) {
return Math.max(Math.abs(src.x - dest.x), Math.abs(src.y - dest.y));
return Math.abs(src.x - dest.x) + Math.abs(src.y - dest.y);
}

function Node(parentNode, src) {
this.parentNode = parentNode;
this.x = src.x;
this.y = src.y;
this.F = 0;
this.G = 0;
this.H = 0;
this.x = src.x;
this.y = src.y;
this.F = 0;
this.G = 0;
this.H = 0;
}

var NodeList = function(sorted, sortParam) {
Expand Down

0 comments on commit 6b97da9

Please sign in to comment.