qiao / PathFinding.js

A comprehensive path-finding library for grid based games
http://qiao.github.io/PathFinding.js/visual/
8.45k stars 1.32k forks source link

Support one-dimensional array Grid #172

Open gugiserman opened 5 years ago

gugiserman commented 5 years ago

I'm currently working on a project that renders a tile map based on a one-dimensional array as grid.

So I have to transform that array into a two-dimensional array in order to instantiate a Grid that can be used by the finders.

If I'm not mistaken, it seems that we could have a new Grid that knows how to handle a one-dimensional array while exposing the same API, or even extend PF.Grid to handle a one-dimensional grid argument.

I didn't read all of the finders yet but from what I've seen it would be possible to extend Grid in order to support one-dimensional arrays with no breaking changes to the finders, right?

brean commented 5 years ago

yes, it would be possible to rewrite the getNeighbors-function for this.