flauwekeul / honeycomb

Create hex grids easily, in node or the browser.

Home Page:https://abbekeultjes.nl/honeycomb

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bug: mapped grids don't behave as described

etodanik opened this issue · comments

I'm using 4.0.0-alpha.5

I tried this simple code snippet:
https://github.com/flauwekeul/honeycomb/tree/next#controlling-how-hexes-are-created

It doesn't seem to work, as demonstrated here:
https://stackblitz.com/edit/js-xjvkfz?devToolsHeight=33&file=index.js

What happens is that instead of the following:

// ...
grid.getHex([1, 2])       // Hex {q: 1, r: 2}
mappedGrid.getHex([1, 2]) // Hex {q: 1, r: 2, custom: 'custom'}

We get this:

// ...
grid.getHex([1, 2])       // Hex {q: 1, r: 2}
mappedGrid.getHex([1, 2]) // Hex {q: 1, r: 2}

Since it clearly deviates from the stated behaviour I'd imagine it's a bug? If not, it'd be nice to understand what the behaviour should actually be.

I went ahead and tried to git clone the next branch and see if I could fix this branch, but I just realized that it's in the middle of a quite massive refactor? None of the grid tests are passing, files are missing, types are going crazy.

I'd love to know how I could help :)

That's a bug alright, thanks for finding and reporting it. As stated in #82, the next branch is currently very unusable. If you're really depending on the 4.0.0-alpha.5 working and having that bug fixed, I could move the refactor to a different branch, revert next to something resembling 4.0.0-alpha.5 and try to fix the bug. But keep in mind that the next alpha will have a different API from the current (the things related to Grid anyway). Another solution could be that you use the stable v3 version.

Please let me know what you prefer.

Honestly, I've already figured out all your changes and made myself work with your new branch, transducers and traversers and all =) So I'm perfectly fine with you hacking away on next. I'm perfectly fine consuming quite unstable code =)

I managed to implement A* path finding, and extrapolate it into functions that show the "traversible path" including obstacles e.t.c on the grid.

Your tanks example was very helpful as practical documentation.

Great 😀 I just pushed another example that happens to showcase (nearly complete) A* path finding using Honeycomb.

I'll close this issue then.

P.S. Please let me know if you find any more issues or think things are counter intuitive or if you need certain features. Thanks!

You're a legend @flauwekeul