New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

aestar

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aestar

Aestar is an A* pathfinding algorithm for TypeScript

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
0
Created
Source

Aestar

Aestar is an A* pathfinding algorithm library for TypeScript which uses async calls to calculate the path and supports dynamic updating of grids. Unlike most A* star pathfinding libraries Aestar does not use a multidimensional array but a class instead. This allows for easier access to grid nodes and dynamically updating those nodes.

Installation

npm install aestar

Usage

import {Grid, Pathfinder} from "aestar";

const grid: Grid = new Grid(30, 20);
const pathfinder: Pathfinder = new Pathfinder();

// Let's block some nodes first on the grid
for (let x=0; x<30; x++) {
    for (let y=0; y<30; y++) {
        const blocked = Math.random() > 0.5;
        const node = grid.getNode(x, y);
        node.blocked = blocked;
    
        // Optional way to access the node is by calculating the index and modifying it from there
        grid.nodes[x * grid.height + y].blocked = blocked;
    }
}

// Now find a path
const nodeStart = grid.getNode(3, 3);
const nodeEnd = grid.getNode(20, 20);
const path = await pathfinder.findPath(grid, nodeStart, nodeEnd);

// If the path is null it means no path was found
if (path == null) {
    console.log("No path found");
    return;
}

// Otherwise log it
for (let node of path) {
    console.log(node);
}

Contribution

Pull requests are welcome. But if you want to make changes, please do so on the develop branch. Thanks!

License

MIT

Keywords

astar

FAQs

Package last updated on 17 Nov 2024

Did you know?

Socket

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.

Install

Related posts