Giter Club home page Giter Club logo

async-node-astar's Introduction

a-star

Generic synchronous A* search algorithm.

Usage

var aStar = require('a-star');
// if this is going to take a while you may want to child_process.fork
// and pass the results to the parent process
// see below for options
var path = aStar(options);
console.log(path);

Documentation

aStar(options)

Return Value

Returns an object that looks like this:

{
  status: 'success', // one of ['success', 'noPath', 'timeout']
  path: [startNode, node1, node2, ..., endNode],
  cost: cost, // cost of path
}

If status is:

  • success - a path was found and path is an array of nodes including start and end.
  • noPath - there is no path from start to end. path is the path to the closest node to end that could be found.
  • timeout - no path was found in the allotted time. path is the path to the closest node that could be found in the allotted time.

options accepted

  • start - the start node
  • isEnd - function(node) that returns whether a node is an acceptable end
  • neighbor - function(node) that returns an array of neighbors for a node
  • distance - function(a, b) that returns the distance cost between two nodes
  • heuristic - function(node) that returns a heuristic guess of the cost from node to an end.
  • hash - function(node) that returns a unique string for a node. this is so that we can put nodes in heap and set data structures which are based on plain old JavaScript objects. Defaults to using node.toString.
  • timeout - optional limit to amount of milliseconds to search before returning null.

The data type for nodes is unrestricted.

async-node-astar's People

Contributors

andrewrk avatar dominictarr avatar navispeed avatar

Watchers

 avatar  avatar

Forkers

idanho

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.