diff --git a/a-star/defaultSettings.js b/a-star/defaultSettings.js index 52207e9..d8ddb5d 100644 --- a/a-star/defaultSettings.js +++ b/a-star/defaultSettings.js @@ -11,7 +11,13 @@ module.exports = { NO_PATH: NO_PATH, // heap settings - setHeapIndex: setHeapIndex + setHeapIndex: setHeapIndex, + + // nba: + setH1: setH1, + setH2: setH2, + compareF1Score: compareF1Score, + compareF2Score: compareF2Score, } function blindHeuristic(/* a, b */) { @@ -32,4 +38,20 @@ function compareFScore(a, b) { function setHeapIndex(nodeSearchState, heapIndex) { nodeSearchState.heapIndex = heapIndex; +} + +function compareF1Score(a, b) { + return a.f1 - b.f1; +} + +function compareF2Score(a, b) { + return a.f2 - b.f2; +} + +function setH1(node, heapIndex) { + node.h1 = heapIndex; +} + +function setH2(node, heapIndex) { + node.h2 = heapIndex; } \ No newline at end of file diff --git a/a-star/nba.js b/a-star/nba.js index 144a217..3c29103 100644 --- a/a-star/nba.js +++ b/a-star/nba.js @@ -60,12 +60,12 @@ function nba(graph, options) { // the nodes that we still need to evaluate var open1Set = new NodeHeap({ - compare: function(a, b) { return a.f1 - b.f1; }, - setNodeId: function(node, heapIndex) { node.h1 = heapIndex } + compare: defaultSettings.compareF1Score, + setNodeId: defaultSettings.setH1 }); var open2Set = new NodeHeap({ - compare: function(a, b) { return a.f2 - b.f2; }, - setNodeId: function(node, heapIndex) { node.h2 = heapIndex } + compare: defaultSettings.compareF2Score, + setNodeId: defaultSettings.setH2 }); var minNode;