Skip to content

Commit

Permalink
11.02.2019
Browse files Browse the repository at this point in the history
Prepared for release
  • Loading branch information
Suficio committed Feb 11, 2019
1 parent 8cb1052 commit 41a96d9
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 14 deletions.
7 changes: 6 additions & 1 deletion DefaultConditions/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
# Default Condition
# Default Conditions

## Method of Operation
To determine which blocks to check the condition of the default function draws from positions and conditions specified in the `predecessorConditions.json` or `successorConditions.json` files.

The function iterates down the json file recursively, when encountering a `condition` node it indicates that that condition must be met for the block position specified in `blockconditions` and all other positions after it. Whereas a failed `nc_condition` still allows the conditions for any further `blockconditions` to be met.
1 change: 1 addition & 0 deletions Pathfinders/ASTAR.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module.exports = function(bot, sp, ep)
function ASTARReturnState(MainPromise)
{
const ReturnState = this;

this.on = function(Callback)
{
MainPromise.then(function(IntermediateObject)
Expand Down
7 changes: 3 additions & 4 deletions Pathfinders/DLITE.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ module.exports = function(bot, sp, ep)
Callback(ReturnState);
};

MainPromise.then(function(IntermediateObject)
{
ResolveFunction(IntermediateObject);
}).catch(function(e) {console.error('ERROR Pathfinder:', e);});
MainPromise
.then(ResolveFunction)
.catch(function(e) {console.error('ERROR Pathfinder:', e);});
};

// Path functions
Expand Down
5 changes: 2 additions & 3 deletions Pathfinders/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

## Table of Contents
- [Algorithm Documentation](#algorithm-documentation)
- [Table of Contents](#table-of-contents)
- [A* Pathfinding](#a-pathfinding)
- [ASTARReturnState](#astarreturnstate)
- [ASTARReturnState.on( Callback)](#astarreturnstateon-callback)
Expand All @@ -16,7 +15,7 @@
- [DLITEReturnState.path.pop()](#dlitereturnstatepathpop)
- [DLITEReturnState.path.peek()](#dlitereturnstatepathpeek)
- [DLITEReturnState.path.replan()](#dlitereturnstatepathreplan)
- [JPS A* Pathfinding \[Not implemented]](#jps-a-pathfinding-\not-implemented)
- [JPS A* Pathfinding [Not implemented]](#jps-a-pathfinding-not-implemented)

## A* Pathfinding
Standard A* algorithim as per Peter E. Hart, Nils J. Nilsson, Bertram Raphael, 1968.
Expand Down Expand Up @@ -80,7 +79,7 @@ Returns position vector.
Recomputes the global state, when complete the function provided in `DLITEReturnState.on` is run again.


## JPS A* Pathfinding \[Not implemented]
## JPS A* Pathfinding [Not implemented]
Jump Point Search as per Daniel Harabor, Alban Grastien, 2011.
Should you want to learn how the algorithm works: http://users.cecs.anu.edu.au/~dharabor/data/papers/harabor-grastien-aaai11.pdf.

Expand Down
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,27 @@ bot.on('chat', function(username, message)
{
bot.move.along(ReturnState.path).then(function(MoveReturn)
{
// Checks if this is a replan as the peek method will return undefined.
if (MoveReturn === bot.move.ENUMStatus.Arrived)
// Checks if bot hasnt moved since last replan
if (lastPoint && lastPoint.equals(bot.entity.position.floored()))
bot.chat('I\'ve been blocked!');

else if (MoveReturn === bot.move.ENUMStatus.Arrived)
{
// Will call function specified in bot.pathfinder.on again, once replan is complete.
// Checks if this is a replan appropiate situation
if (!endPoint.equals(bot.entity.position.floored()))
{
lastPoint = bot.entity.position.floored();
// Will call this function again when completed
ReturnState.path.replan();
}
else
bot.chat('I\'ve arrived!');
}
else
{
lastPoint = bot.entity.position.floored();
ReturnState.path.replan();
}
});
});
});
Expand Down
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ module.exports = function(bot)
// All in all the user is encouraged to supply his own successor or predecessor functions.

bot.pathfinder = {};
bot.pathfinder.ENUMPathfinder = {ASTAR: 0, DLITE: 1, UDLITE: 2};
bot.pathfinder.ENUMStatus = {Complete: 0, Incomplete: 1, Replan: 2};
bot.pathfinder.ENUMPathfinder = {ASTAR: 0, DLITE: 1};
bot.pathfinder.ENUMStatus = {Complete: 0, Incomplete: 1};

Object.defineProperty(bot.pathfinder, 'defaultSuccessors', {
value: require(Path.resolve(__dirname, 'DefaultConditions/successorConditions.json')), enumerable: false,
Expand Down Expand Up @@ -66,7 +66,7 @@ module.exports = function(bot)
return require(Path.resolve(__dirname, 'Pathfinders/DLITE.js'))(bot, Start.floored(), End.floored());
};

bot.pathfinder.MAX_EXPANSIONS = 120000; // 100000
bot.pathfinder.MAX_EXPANSIONS = 100000; // 100000
bot.pathfinder.HEURISTIC = function(p1, p2) {return p1.distanceTo(p2);};
bot.pathfinder.COST = bot.pathfinder.HEURISTIC;

Expand Down

0 comments on commit 41a96d9

Please sign in to comment.