spectre-tables-manual.h 3.8 KB

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