I want a basic rectangular shaped graph, but instead of squares, hexagons. It can be row major, or column major which means any of these shapes:
https://www.redblobgames.com/grids/hexagons/#coordinates-offset
But to achieve that I have to setup Astar like this:
I’m just not “getting” why it isn’t a rectangle setup like grid that fits hexagons within the surface. Am I doing something wrong?
Hi
This is simply due to how the graph is represented internally. Representing a a hexagonal graph using alternating offsets for every second row is a bit more complicated compared to the currently used approach, which can be achieved using a simple matrix multiplication. The grid graph existed long before hexagonal graph support was added, and I wanted to keep as much backwards compatible as possible. In hindsight it might have been better to do it some other way.
Thanks for reply Aron. So I should just try to fit the grid to the board shape as best I can and not worry about the wasted areas?
Yes, that will work fine. Unless your world is huge, I wouldn’t worry about it at all.