Skip to content

Commit

Permalink
preventing the error when gScore.get(id(child)) == 0
Browse files Browse the repository at this point in the history
  • Loading branch information
nervgh committed Jul 27, 2017
1 parent 2151346 commit b6b6af8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function astar (start, goal, {id, isGoal, getSuccessors, distance, estimate}) {

// The distance from start to a child
const tentativeGScore = gScore.get(id(node)) + distance(node, child)
const childGScore = gScore.get(id(child)) || Infinity
const childGScore = gScore.has(id(child)) ? gScore.get(id(child)) : Infinity

// This is not a better path
if (tentativeGScore >= childGScore) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "astar-algorithm",
"version": "0.1.1",
"version": "0.1.2",
"homepage": "https://github.com/nervgh/astar-algorithm",
"description": "An almost universal implementation of A* search algorithm in JavaScript",
"main": "lib/index.js",
Expand Down

0 comments on commit b6b6af8

Please sign in to comment.