I need to create a hex-tile map, using at most 19 colors, where each color must keep a distance of at least 3 tiles. However, I do not need to use all 19 colors. If there exists an algorithm that solves this distance constraint with less than 19 colors, this is completely fine.
The Beckman-Quarles theorem [1] looks related, and there is a 7-color tile map shown where same colored tiles keep a distance of 2 to each other.
But I have a hard time to find an understandable description or even implementation for constructing a hex tile map with a distance of 3.
[1] http://de.wikipedia.org/wiki/Satz_von_Beckman_und_Quarles
Let's set up a coordinate system where the hex with coordinates
(i,j)
is adjacent to(i-1,j), (i-1,j+1), (i,j-1), (i,j+1), (i+1,j-1), (i+1,j)
.I'm going to apply a shear transform so that I can draw hex grids compactly with ASCII art. The transformed 7-hex region looks like this.
What you want to do is tile the plane with the following 19-color layout.
The tiles can fit together like so.
I've marked the tile centers with
-
. These form a lattice generated by two vectors:(5,-3)
and(3,2)
. Given hex coordinates(i,j)
, we can (inelegantly, perhaps) solve the matrix equationin rational variables
u, v
, then, trying all four integer roundings ofu
andv
to nearby integersu*
andv*
respectively, determine which tile(i,j)
lies in and apply the appropriate color, where the tile center is