summaryrefslogtreecommitdiff
path: root/apps/plugins/puzzles/src/spectre-tables-manual.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/puzzles/src/spectre-tables-manual.h')
-rw-r--r--apps/plugins/puzzles/src/spectre-tables-manual.h160
1 files changed, 160 insertions, 0 deletions
diff --git a/apps/plugins/puzzles/src/spectre-tables-manual.h b/apps/plugins/puzzles/src/spectre-tables-manual.h
new file mode 100644
index 0000000000..d57e6597dd
--- /dev/null
+++ b/apps/plugins/puzzles/src/spectre-tables-manual.h
@@ -0,0 +1,160 @@
1/*
2 * Handwritten data tables for the Spectre tiling.
3 *
4 * This file is used by both the final tiling generator in spectre.c,
5 * and by spectre-gen.c which auto-generates further tables to go with
6 * these.
7 */
8
9/*
10 * We generate the Spectre tiling based on the substitution system of
11 * 9 types of marked hexagon shown in the paper.
12 *
13 * The substitution expands each hexagon into 8 others, except for the
14 * G hex which expands to only seven. The layout, numbered with the
15 * indices we use in the arrays here, is as follows:
16 *
17 * 0 1
18 * 2 3
19 * 4 5 6
20 * 7
21 *
22 * That is: the hexes are oriented with a pair of vertical edges.
23 * Hexes 0 and 1 are horizontally adjacent; 2 and 3 are adjacent on
24 * the next row, with 3 nestling between 0 and 1; 4,5,6 are on the
25 * third row with 5 between 2 and 3; and 7 is by itself on a fourth
26 * row, between 5 and 6. In the expansion of the G hex, #7 is the
27 * missing one, so its indices are still consecutive from 0.
28 *
29 * These arrays list the type of each child hex. The hexes also have
30 * orientations, but those aren't listed here, because only
31 * spectre-gen needs to know them - by the time it's finished
32 * autogenerating transition tables, the orientations are baked into
33 * those and don't need to be consulted separately.
34 */
35
36static const Hex subhexes_G[] = {
37 HEX_F,
38 HEX_X,
39 HEX_G,
40 HEX_S,
41 HEX_P,
42 HEX_D,
43 HEX_J,
44 /* hex #7 is not present for this tile */
45};
46static const Hex subhexes_D[] = {
47 HEX_F,
48 HEX_P,
49 HEX_G,
50 HEX_S,
51 HEX_X,
52 HEX_D,
53 HEX_F,
54 HEX_X,
55};
56static const Hex subhexes_J[] = {
57 HEX_F,
58 HEX_P,
59 HEX_G,
60 HEX_S,
61 HEX_Y,
62 HEX_D,
63 HEX_F,
64 HEX_P,
65};
66static const Hex subhexes_L[] = {
67 HEX_F,
68 HEX_P,
69 HEX_G,
70 HEX_S,
71 HEX_Y,
72 HEX_D,
73 HEX_F,
74 HEX_X,
75};
76static const Hex subhexes_X[] = {
77 HEX_F,
78 HEX_Y,
79 HEX_G,
80 HEX_S,
81 HEX_Y,
82 HEX_D,
83 HEX_F,
84 HEX_P,
85};
86static const Hex subhexes_P[] = {
87 HEX_F,
88 HEX_Y,
89 HEX_G,
90 HEX_S,
91 HEX_Y,
92 HEX_D,
93 HEX_F,
94 HEX_X,
95};
96static const Hex subhexes_S[] = {
97 HEX_L,
98 HEX_P,
99 HEX_G,
100 HEX_S,
101 HEX_X,
102 HEX_D,
103 HEX_F,
104 HEX_X,
105};
106static const Hex subhexes_F[] = {
107 HEX_F,
108 HEX_P,
109 HEX_G,
110 HEX_S,
111 HEX_Y,
112 HEX_D,
113 HEX_F,
114 HEX_Y,
115};
116static const Hex subhexes_Y[] = {
117 HEX_F,
118 HEX_Y,
119 HEX_G,
120 HEX_S,
121 HEX_Y,
122 HEX_D,
123 HEX_F,
124 HEX_Y,
125};
126
127/*
128 * Shape of the Spectre itself.
129 *
130 * Vertex 0 is taken to be at the top of the Spectre's "head"; vertex
131 * 1 is the adjacent vertex, in the direction of the shorter edge of
132 * its "cloak".
133 *
134 * This array indicates how far to turn at each vertex, in 1/12 turns.
135 * All edges are the same length (counting the double-edge as two
136 * edges, which we do).
137 */
138static const int spectre_angles[14] = {
139 -3, -2, 3, -2, -3, 2, -3, 2, -3, -2, 0, -2, 3, -2,
140};
141
142/*
143 * The relative probabilities of the nine hex types, in the limit, as
144 * the expansion process is iterated more and more times. Used to
145 * choose the initial hex coordinates as if the segment of tiling came
146 * from the limiting distribution across the whole plane.
147 *
148 * This is obtained by finding the matrix that says how many hexes of
149 * each type are expanded from each starting hex, and taking the
150 * eigenvector that goes with its limiting eigenvalue.
151 */
152#define PROB_G 10000000 /* 1 */
153#define PROB_D 10000000 /* 1 */
154#define PROB_J 1270167 /* 4 - sqrt(15) */
155#define PROB_L 1270167 /* 4 - sqrt(15) */
156#define PROB_X 7459667 /* 2 sqrt(15) - 7 */
157#define PROB_P 7459667 /* 2 sqrt(15) - 7 */
158#define PROB_S 10000000 /* 1 */
159#define PROB_F 17459667 /* 2 sqrt(15) - 6 */
160#define PROB_Y 13810500 /* 13 - 3 sqrt(15) */