ETOOBUSY ðŸš€ minimal blogging for the impatient
Hexagonal grids
TL;DR
Some words on hexagonal grids, and a pointer to something serious: Hexagonal Grids on Red Blob Games.
In recent post The Definitive Conwayâ€™s Game of Life I made a quick and vague reference to using a hexagonal grid for playing Conwayâ€™s Game of Life. So I thought that maybe some additional hints might be useful as well.
In that specific challenge, a simple representation of the whole grid based on two coordinates was sufficient:
 take any hexagon in your grid and consider it your origin;
 that hexagon has three pairs of opposite sides;
 choose one pair and consider that as your $X$ dimension. Make it increase as you move right (or up, if the two sides are stacked vertically);
 choose a different pair and consider that as your $Y$ dimension. Again, make it increase with the same rules as above.
This is actually all you need. From the origin, you can directly reach four of the six adjacent cells by only changing one unit (positive or negative) in one of the dimensions. As an example, assume that the grid is such that hexagons have a flat side on the up/down direction (which is actually not what was happening in the challenge), we might choose $X$ and $Y$ as follows:
^ Y

 ><
 >< ( 0, 1) ><
 < (1, 0) >< >
 >< ( 0, 0) ><
 < >< ( 1, 0) >
 >< ( 0, 1) ><
 ><

\
\
\>
X
Now weâ€™re left with the two missing cells, one rightup and another one leftdown.
Starting from the origin, there are two ways to reach the rightup cell:
 go rightdown first (increase in $X$ only, landing on $(1, 0)$), then up one step (increase in $Y$ only, landing on $(1, 1)$);
 go up first (increase in $Y$ only, landing on $(0, 1)$, the rightdown (increase in $X$ only, landing on $(1, 1)$).
Both way are consistent: the rightup cell is at $(1, 1)$, i.e. it is obtained by increasing one single step in both dimensions.
Itâ€™s easy to see that the same can be done for leftdown, yielding $(1, 1)$, i.e. a decrease in both dimensions.
So, weâ€™re left with the following displacements for all cells adjacent to the origin:
^ Y

 ><
 >< ( 0, 1) ><
 < (1, 0) >< ( 1, 1) >
 >< ( 0, 0) ><
 < (1, 1) >< ( 1, 0) >
 >< ( 0, 1) ><
 ><

\
\
\>
X
Expanding this to the whole planeâ€¦ we get a unique pair of $(x, y)$ coordinates for each cell. Itâ€™s also easy to see that this is equivalent to a square grid, where the neighbors of any cells are the four adjacent ones (in the up, down, left, and right directions), plus the two diagonal ones on the rightup and the leftdown directions. The other two cells in the other diagonalâ€¦ are distant, sorry! The following picture marks with asterisks the cells in this mapping that are considered adjacent to the origin:
 
(1, 1)  *( 0, 1)*  *( 1, 1)*
 
++
 
*(1, 0)*  ( 0, 0)  *( 1, 0)*
 
++
 
*(1, 1)*  *( 0, 1)*  ( 1, 1)
 
In that challenge, though, the hexagons are arranged with flat sides on the leftright direction instead. Again, itâ€™s easy to choose two dimensions and extend what we explained above, e.g. yielding this arrangement for the displacement of cells adjacent to the origin:
( 0, 1) ( 1, 1)
(1, 0) ( 0, 0) ( 1, 0)
(1, 1) ( 0, 1)
Againâ€¦ itâ€™s the same mapping on the square grid: adjacents are all four in the up, down, left, and right, plus the two diagonals in the rightup and leftdown directions.
So much for the challenge. If you really want to understand whatâ€™s going on with the hexagonsâ€¦ your next stop MUST be Hexagonal Grids from Red Blob Games!