
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
@misterhat/easystarjs
Advanced tools
Click here for a demonstration
npm install @misterhat/easystarjseasystar.js is an asynchronous A* pathfinding API written in Javascript for use in your HTML5 games and interactive projects. The goal of this project is to make it easy and fast to implement performance conscious pathfinding.
This fork provides parallel and ndarray support.
var easystar = new EasyStar.js();
easystar.setGrid(twoDimensionalArray || twoDimensionalNdarray);
easystar.setAcceptableTiles(arrayOfAcceptableTiles);
easystar.findPath(startX, startY, endX, endY, callback);
easystar.calculate();
easystar.setIterationsPerCalculation(someValue);
easystar.avoidAdditionalPoint(x, y);
easystar.enableDiagonals();
easystar.enableCornerCutting();
easystar.setAdditionalPointCost(x, y, cost);
easystar.setTileCost(tileType, multiplicativeCost);
easystar.enableSync();
easystar.setDirectionalCondition(x, y, [EasyStar.TOP, EasyStar.LEFT]); // only accessible from the top and left
var instanceId = easystar.findPath(startX, startY, endX, endY, callback);
// ...
easystar.cancelPath(instanceId);
easystar.enableParallelCompute();
First create EasyStar.
// for web
var easystar = new EasyStar.js();
// for node.js
var easystarjs = require('easystarjs');
var easystar = new easystarjs.js();
Create a grid, or tilemap. You may have made this with a level editor, or procedurally. Let's keep it simple for this example.
var grid = [[0,0,1,0,0],
[0,0,1,0,0],
[0,0,1,0,0],
[0,0,1,0,0],
[0,0,0,0,0]];
Set our grid.
easystar.setGrid(grid);
Set tiles which are "walkable".
easystar.setAcceptableTiles([0]);
Find a path.
easystar.findPath(0, 0, 4, 0, function( path ) {
if (path === null) {
alert("Path was not found.");
} else {
alert("Path was found. The first Point is " + path[0].x + " " + path[0].y);
}
});
EasyStar will not yet start calculating my path.
In order for EasyStar to actually start calculating, I must call the calculate() method.
You should call easystar.calculate() on a ticker, or setInterval.
If you have a large grid, then it is possible that these calculations could slow down the browser.
For this reason, it might be a good idea to give EasyStar a smaller iterationsPerCalculation value via
easystar.setIterationsPerCalculation(1000);
It may take longer for you to find a path this way, but you won't completely halt your game trying to find one. The only thing left to do now is to calculate the path.
easystar.calculate();
easystar.js is licensed under the MIT license. You may use it for commercial use.
In order to run the demo you will need node.js, and npm installed.
git clone https://github.com/misterhat/easystarjs.git
cd easystarjs/demo
npm install
node app.js
Open your browser to 127.0.0.1:3000 to see the example.
npm run test
If you have any questions, comments, or suggestions please open an issue.
FAQs
Asynchronous A* Pathfinding API
We found that @misterhat/easystarjs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.