fast-astar

Left mouse button to set the end point, right button (add/delete) obstacle.

About

fast-astar is an implementation of a* algorithm using javascript. Small and fast.

Use

Install fast-astar using npm or introduce Grid.js and Astar.js on the page

Install:
			
# install
npm install fast-astar --save
			
		
Code:
			
import AstarLib, { Grid, Astar } from "./index.js";

const grid = new Grid({ col: 20, row: 12 });
grid.setWalkAt(5, 5, false); // obstacle

const astar = new Astar(grid, { strategy: "auto" }); // or prefer: "master"/"ultra"/"wasm"
const path = await astar.search([0, 0], [19, 11], { rightAngle: false, optimalResult: true });

console.log(path); // [[x,y], ...] or null
console.log(astar.getCurrentImplementation()); // { name, gridSize, environment }
			
		

Related

License

MIT