Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/webbestmaster/a-star-finder
Generic synchronous/asynchronous A* search algorithm.
https://github.com/webbestmaster/a-star-finder
Last synced: about 1 month ago
JSON representation
Generic synchronous/asynchronous A* search algorithm.
- Host: GitHub
- URL: https://github.com/webbestmaster/a-star-finder
- Owner: webbestmaster
- License: mit
- Created: 2017-05-29T18:21:26.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-03-23T17:42:06.000Z (almost 7 years ago)
- Last Synced: 2024-12-16T06:12:01.548Z (2 months ago)
- Language: JavaScript
- Size: 7.81 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# a-star-finder
Generic synchronous/asynchronous A* search algorithm.### How to use
```javascript
// sync version
const {getPath} = require('a-star-finder');const map = [
'··S·###···', // S and E - Start and End, not required, here is for example only
'····#·····', // · - available to across square, not required, here is for example only
'····#E##··', // # - NOT AVAILABLE to across square, REQUIRED
'····###···',
'··········'
];const start = [2, 0]; // x and y coordinates, start of path
const end = [5, 2]; // x and y coordinates, end of path
const path = getPath(map, start, end);console.log(path); // array of square's coordinates [start, [3, 0], [3, 1], ..., [6, 1], [5, 1], end]
// getPath support options
getPath(map, start, end, {noPath: '#'}); // noPath will used instead of default not across square// async version
const {getPathAsync} = require('a-star-finder');// getPathAsync support options: getPathAsync(map, start, end, callback, options)
getPathAsync(map, start, end, path => {
// here your path
console.log(path);
});
```If end point is unreachable, return null.