https://github.com/fenomas/abstract-pathfinder
Completely agnostic A* pathfinding
https://github.com/fenomas/abstract-pathfinder
a-star pathfinding
Last synced: 5 months ago
JSON representation
Completely agnostic A* pathfinding
- Host: GitHub
- URL: https://github.com/fenomas/abstract-pathfinder
- Owner: fenomas
- Created: 2016-11-17T09:21:18.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2024-10-24T01:31:15.000Z (12 months ago)
- Last Synced: 2025-03-31T17:58:44.727Z (6 months ago)
- Topics: a-star, pathfinding
- Language: TypeScript
- Size: 11.7 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# abstract-pathfinder
Type-agnostic A\* pathfinding.
Doesn't care how your data is structured - just implement a minimal set of accessors,
and this module will apply [A\*](https://en.wikipedia.org/wiki/A*_search_algorithm)
to whatever data or graph you're using.Now built in typescript! Takes any arbitrary type for the graph nodes.
### Installation:
```shell
pnpm i abstract-pathfinder
```### Usage:
```ts
import { Pathfinder } from 'abstract-pathfinder'type MyNodeType = { x: number; y: number } // or whatever
const finder = new Pathfinder({
nodeToPrimitive: (node) => 'a', // unique key for each node
getNeighbors: (node) => [], // array of neighboring nodes
getMoveCost: (a, b) => 1 , // move cost between neighboring nodes
getHeuristic: (a, b) => 1, // guess at move cost between arbitrary nodes
})const path = finder.findPath(start, end) // array of nodes, or [] if no path found
```### By:
Made with 🍺 by [fenomas](https://fenomas.com).