[Math] Numbering a spherical grid (of pentagons and hexagons) so neighbours are easily calculated

geometry

I'm making a grid-based game with a spherical world. Currently I'm using a grid of 12 pentagons and variable number of hexagons to create grids of different sizes. So they look like this:

enter image description here

Currently to find which tile boarders which it's basically hard-coded. I just have a file with all of this information for each size of grid I support.

I was however wondering, would it be possible to give each tile a number in such a way that it's relatively simple to calculate the neighboring tile's number from it? On a planar rectangular grid this is simple: neighbours(a,b) = [(a-1,b), (a+1,b), (a,b-1), (a,b+1)]. But is there some smart numbering scheme for this kind of grid that allows?

I'm not expecting the calculating to be as easy as those for the rectagle grid, but anything that's not just hard-coded data would be interesting. Depending on how simple it is I will be using the data of this numbering scheme, but either way it's something interesting to know I think.

Best Answer

This is not an answer, but explores the features of the mapping/connectivity of the .. tiles.

I do believe that the smallest such sphere is described by the truncated rhombic triacontahedron with one hexagon between each pair of pentagons); the next one is the Conway polyhedron with two hexagons between each pair of pentagons, and so on.

The 12 pentagons are located at the vertices of a regular icosahedron. (Or, equivalently, at the centers of each face of a regular dodecahedron, those two being duals.)

This means there are 20 "faces" with a group of hexagons in each, and 30 edges (rows of hexagons between two pentagons).

If we use $N$ for the number of hexagons between each pair of pentagons, $N = 0$ would correspond to a dodecahedron, $N = 1$ to a truncated rhombic triacontahedron, $N = 2$ to a Conway polyhedron, and so on. Let us exclude the $N = 0$ case, because there would be no hexagons at all in that case, so it'd be a special case anyway.

If we exclude the hexagons directly between two pentagons from each hexagon group, we have a triangular group of hexagons with $N-1$ on each side; thus, each such group is composed of $$\frac{N (N - 1)}{2}$$ hexagons; see e.g. triangular number at wikipedia for explanation.

So, we end up with

  • $N_p = 12$ pentagons (each at the vertex of an icosahedron)

  • $N_b = 30 N$ hexagons, total (between each pair of pentagons, only considering pentagons connected by a corresponding edge in an icosahedron, of course)

  • $N_h = 20 N (N+1) / 2 = 10 N (N-1)$ hexagons, total (in the triangular groups of hexagons, corresponding roughly to the faces of a dodecahedron)

and therefore 12 pentagons and $10 N (N-1) + 30 N = 10 N (N+2) = 10 N^2 + 20 N$ hexagons, total, for $0 \le N \in \mathbb{Z}$.

To generate a connectivity graph or matrix -- myself preferring a graph, because that makes it easier to specify which edge of a tile is connected to which edge of another tile --, I'd first construct the 30 strings of hexagonal tiles, each a straight line, and connect their ends to the pentagons. Note that there are logically two different types of such lines of tiles: with an odd number of tiles, and an even number of tiles. The ones with an even number of tiles are easier to construct and connect, so you might wish to restrict $N$ to an even number.

Next, I'd create the 20 sets of hexagons arranged in a triangle with $N-1$ hexagons per side, and their interconnections. I think row by row should work fine, starting with a longest row. Stitching them into three tile strings already connected to the pentagons depends on the orientation of the group, so you might wish to write different functions for different groups, to make stitching them in to the graph or matrix easier.

All in all, I don't see any particular point of difficulty, except for the extreme care to detail and checking needed to make sure it works correctly. For example, if you number the edges counterclockwise from $0$ to $4$ for the pentagons, and from $0$ to $5$ for the hexagons, then a connectivity graph will have exactly one undirected edge from one edge to one other edge; this also explicitly defines the orientation of each pentagon/hexagon in relation to its neighbours. I would personally use some software to use 3D, maybe balls to represent the nodes and sticks for edges in the graph, so that verifying each step of stitching would be easier.

A similar technique can be used in 3D, constructing non-Euclidean geometries with each room/tile having local Euclidean geometry; like in the movie Cube. You just have compatible openings between tiles, and decide which tiles share an opening (an edge in 2D, a face in 3D). (In 3D -- and in 2D too, if you count reflecting/mirroring --, you also need to specify the rotation and/or reflection around the axis between the two.)

Hmm. Are there any board games using tiles that can be flipped, that represent two different worlds? Maybe with the board vertical between the players, so each player only sees their own side? Might lead to interesting gameplay mechanics, if the tile face pairings and the rules for flipping a tile work...