You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The HexIDs are 64-bit unsigned integers used by a Hexmap to uniquely identify its Hexes. These numbers are constructed using the Hexes' location on the hex grid; allowing a discrete one-to-one and onto mapping between the HexIDs and positions on the hex grid!
The Hexgrid
HexIDs can be deconstructed to return a position on the hex grid.
First, consider a hexagonal tiling of 2D space where the hexes are stacked vertically. This tiling is sub-divided into two grids as shown below: the primary grid (red) and the secondary grid (blue).
The sub-grids are essentially regular rectangular lattices; indexing them is extremely easy. We choose a Hex centered at coordinate (0,0). This hex has x and y indices of zero.
The Bits
Bit 0: used to specify the primary or secondary grid.
Bit 1: unused
Bits 2-32: signed integer. Represents the x-index of the hex on the grid specified by bit 0.
Bits 33-63: signed integer. Represents the y-index of the hex on the grid specified by bit 0.