If I had a grid of squares, they can be labeled with Cartesian coordinates such that given square (*x*,*y*), you know it shares a boundary with squares (*x*+1,*y*),(*x*−1,*y*),(*x*,*y*+1),(*x*,*y*−1)

.

Is there a way of labeling a tessellated hexagon grid, so that given any hexagon label you can work out it’s neighbors?

Create the grid by drawing horizontal lines thru ALL hexagon centers and drawing vertical lines thru ALL hexagon centers. The neighbors are:

(+1,-1), (+2,0), (+1,+1), (-1,+1), (-2,0), (-1,-1)

Note: the x-axis is scaled by a factor of sqrt(3). This is ok. Cartesian coordinates can have an axis that is scaled.

Note: the x,y does not match the hexagon label. This is ok.

If we set the upper left hexagon with a coordinate of (0,0), the hexagon label is: Math.floor(x/2)+1 plus y+1

(0,0) => 0101 (2,0) => 0201 (4,0) => 0301 (1,1) => 0102 (3,1) => 0202 (5,1) => 0302