1.0.10 • Published 4 years ago

grid-path-finder v1.0.10

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

grid-path-finder

NPM module for path-finding on a grid by Ruaidhri MacKenzie.

An NPM module that finds the shortest path between two nodes on a grid. Exposes a function which accepts two positions and a grid. The positions are objects with x and y properties. The grid is a 2d array with values of 0 (vacant node) or 1 (wall node).

npm install grid-path-finder

Example

const pathFinder = require('grid-path-finder');

const startPos = {x: 0, y: 0};
const endPos = {x: 5, y: 0};
const grid = [
  [0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0],
  [1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0],
  [0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
];
const path = pathFinder(startPos, endPos, grid);
1.0.10

4 years ago

1.0.9

5 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago