Skip to content

Commit

Permalink
12.12.2018
Browse files Browse the repository at this point in the history
General Work
- D*Lite Preliminary CSP Algorithim Completed
- Stack functions lightly optimizied
- Specialized ReturnStates
  • Loading branch information
Suficio committed Dec 12, 2018
1 parent 52841d4 commit e6b820f
Show file tree
Hide file tree
Showing 5 changed files with 354 additions and 161 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
indexD.js
indexOld.js
38 changes: 20 additions & 18 deletions Pathfinders/ASTAR.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,24 @@ function State(p)
this.cF = null;
}

function ReturnState(MainPromise)
function ASTARReturnState(MainPromise)
{
this.MainPromise = MainPromise;
this.MainPromise
.then(function(ENUMStatus, State)
{
this.ENUMStatus = IntermediateState.ENUMStatus;
const ReturnState = this;
this.on = function(Callback) {MainPromise.then(function() {Callback(ReturnState);});};

const Path = [State.p];
while (State.cF)
{
State = State.cF;
Path.push(State.p);
}
this.Path = Path;
}.bind(this))
MainPromise.then(function(IntermediateObject)
{
ReturnState.ENUMStatus = IntermediateObject.ENUMStatus;

let State = IntermediateObject.State;
const Path = [State.p];
while (State.cF)
{
State = State.cF;
Path.push(State.p);
}
ReturnState.Path = Path;
})
.catch(function() {return;});
}

Expand Down Expand Up @@ -81,8 +83,8 @@ module.exports = function(bot, sp, ep)
};
O.replace = function(i, s)
{
// Priority queue handles the perlocation automatically eitherway
this.array[i] = s;
this._percolateUp(i);
};

// Maintain familiarity with original heap implementation
Expand All @@ -106,7 +108,7 @@ module.exports = function(bot, sp, ep)
{
const current = O.pop();
if (current.p.equals(end.p))
return resolve(bot.navigate.ENUMStatus.Complete, current);
return resolve({ENUMStatus: bot.navigate.ENUMStatus.Complete, State: current});

C.push(current);

Expand All @@ -132,8 +134,8 @@ module.exports = function(bot, sp, ep)
};

console.log('WARNING: Did not find path in allowed MAX_EXPANSIONS, returned closest path');
return resolve(bot.navigate.ENUMStatus.Incomplete, CP(closest));
return resolve({ENUMStatus: bot.navigate.ENUMStatus.Incomplete, State: closest});
});

return new ReturnState(MainPromise);
return new ASTARReturnState(MainPromise);
};
Loading

0 comments on commit e6b820f

Please sign in to comment.