aboutsummaryrefslogtreecommitdiff
path: root/spectre-tables-manual.h
blob: d57e6597ddcb4b244e69031d424d46d56321a3b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/*
 * Handwritten data tables for the Spectre tiling.
 *
 * This file is used by both the final tiling generator in spectre.c,
 * and by spectre-gen.c which auto-generates further tables to go with
 * these.
 */

/*
 * We generate the Spectre tiling based on the substitution system of
 * 9 types of marked hexagon shown in the paper.
 *
 * The substitution expands each hexagon into 8 others, except for the
 * G hex which expands to only seven. The layout, numbered with the
 * indices we use in the arrays here, is as follows:
 *
 *     0 1
 *    2 3
 *   4 5 6
 *      7
 *
 * That is: the hexes are oriented with a pair of vertical edges.
 * Hexes 0 and 1 are horizontally adjacent; 2 and 3 are adjacent on
 * the next row, with 3 nestling between 0 and 1; 4,5,6 are on the
 * third row with 5 between 2 and 3; and 7 is by itself on a fourth
 * row, between 5 and 6. In the expansion of the G hex, #7 is the
 * missing one, so its indices are still consecutive from 0.
 *
 * These arrays list the type of each child hex. The hexes also have
 * orientations, but those aren't listed here, because only
 * spectre-gen needs to know them - by the time it's finished
 * autogenerating transition tables, the orientations are baked into
 * those and don't need to be consulted separately.
 */

static const Hex subhexes_G[] = {
    HEX_F,
    HEX_X,
    HEX_G,
    HEX_S,
    HEX_P,
    HEX_D,
    HEX_J,
    /* hex #7 is not present for this tile */
};
static const Hex subhexes_D[] = {
    HEX_F,
    HEX_P,
    HEX_G,
    HEX_S,
    HEX_X,
    HEX_D,
    HEX_F,
    HEX_X,
};
static const Hex subhexes_J[] = {
    HEX_F,
    HEX_P,
    HEX_G,
    HEX_S,
    HEX_Y,
    HEX_D,
    HEX_F,
    HEX_P,
};
static const Hex subhexes_L[] = {
    HEX_F,
    HEX_P,
    HEX_G,
    HEX_S,
    HEX_Y,
    HEX_D,
    HEX_F,
    HEX_X,
};
static const Hex subhexes_X[] = {
    HEX_F,
    HEX_Y,
    HEX_G,
    HEX_S,
    HEX_Y,
    HEX_D,
    HEX_F,
    HEX_P,
};
static const Hex subhexes_P[] = {
    HEX_F,
    HEX_Y,
    HEX_G,
    HEX_S,
    HEX_Y,
    HEX_D,
    HEX_F,
    HEX_X,
};
static const Hex subhexes_S[] = {
    HEX_L,
    HEX_P,
    HEX_G,
    HEX_S,
    HEX_X,
    HEX_D,
    HEX_F,
    HEX_X,
};
static const Hex subhexes_F[] = {
    HEX_F,
    HEX_P,
    HEX_G,
    HEX_S,
    HEX_Y,
    HEX_D,
    HEX_F,
    HEX_Y,
};
static const Hex subhexes_Y[] = {
    HEX_F,
    HEX_Y,
    HEX_G,
    HEX_S,
    HEX_Y,
    HEX_D,
    HEX_F,
    HEX_Y,
};

/*
 * Shape of the Spectre itself.
 *
 * Vertex 0 is taken to be at the top of the Spectre's "head"; vertex
 * 1 is the adjacent vertex, in the direction of the shorter edge of
 * its "cloak".
 *
 * This array indicates how far to turn at each vertex, in 1/12 turns.
 * All edges are the same length (counting the double-edge as two
 * edges, which we do).
 */
static const int spectre_angles[14] = {
    -3, -2, 3, -2, -3, 2, -3, 2, -3, -2, 0, -2, 3, -2,
};

/*
 * The relative probabilities of the nine hex types, in the limit, as
 * the expansion process is iterated more and more times. Used to
 * choose the initial hex coordinates as if the segment of tiling came
 * from the limiting distribution across the whole plane.
 *
 * This is obtained by finding the matrix that says how many hexes of
 * each type are expanded from each starting hex, and taking the
 * eigenvector that goes with its limiting eigenvalue.
 */
#define PROB_G 10000000                /* 1 */
#define PROB_D 10000000                /* 1 */
#define PROB_J  1270167                /* 4 - sqrt(15) */
#define PROB_L  1270167                /* 4 - sqrt(15) */
#define PROB_X  7459667                /* 2 sqrt(15) - 7 */
#define PROB_P  7459667                /* 2 sqrt(15) - 7 */
#define PROB_S 10000000                /* 1 */
#define PROB_F 17459667                /* 2 sqrt(15) - 6 */
#define PROB_Y 13810500                /* 13 - 3 sqrt(15) */