1 /* Copyright (c) 2014 Brendan Hickey
2  * All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without modification,
5  * are permitted provided that the following conditions are met:
6  *
7  * 1. Redistributions of source code must retain the above copyright notice, this
8  * list of conditions and the following disclaimer.
9  *
10  * 2. Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation and/or
12  * other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
18  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  **/
25 
26 #pragma once
27 
28 #include "domino.h"
29 
30 namespace domino {
31 
32 // This set of eight tiles trivially cover the plane.
33 // See: Wang Tiles for Image and Texture Generation (Cohen, 2003)
34 #define R 0
35 #define G 1
36 #define B 2
37 #define Y 3
38 static EdgeDomino cohen_set[8] = {
39   {R, Y, G, B}, {G, B, G, B}, {R, Y, R, Y}, {G, B, R, Y},
40   {R, B, G, Y}, {G, Y, G, Y}, {R, B, R, B}, {G, Y, R, B},
41 };
42 
43 #undef R
44 #undef G
45 #undef B
46 #undef Y
47 
48 static OrientedDomino oriented_set[4] = {
49   { 1,  1, -1, -1},
50   { 1, -1, -1, -1},
51   { 1, -1, -1, 1},
52   { 1,  1, -1, 1},
53 };
54 
55 // This is a six-colour set of 44 tiles.
56 // See: Aperiodic Sets of Square Tiles with Colored Corners (Lagae, 2006)
57 static CornerDomino aperiodic_set[44] = {
58   // Row 1
59   {0, 4, 1, 2}, {0, 3, 1, 5},
60   {0, 2, 1, 5}, {2, 3, 3, 4},
61   {2, 2, 3, 4}, {2, 1, 3, 0},
62   {3, 1, 4, 0}, {3, 0, 4, 0},
63   {5, 2, 2, 3}, {5, 3, 2, 3},
64   {5, 5, 2, 3},
65   // Row 2
66   {5, 1, 2, 1}, {3, 1, 3, 0},
67   {3, 0, 3, 0}, {5, 2, 3, 3},
68   {5, 3, 3, 3}, {5, 5, 3, 3},
69   {5, 1, 3, 1}, {2, 3, 4, 4},
70   {2, 2, 4, 4}, {2, 1, 4, 0},
71   {2, 3, 2, 4},
72   // Row 3
73   {2, 2, 2, 4}, {2, 1, 2, 0},
74   {4, 0, 2, 1}, {4, 4, 2, 3},
75   {3, 0, 5, 1}, {3, 4, 5, 3},
76   {4, 0, 3, 1}, {4, 4, 3, 3},
77   {2, 4, 5, 2}, {2, 3, 5, 5},
78   {2, 2, 5, 5},
79   // Row 4
80   {1, 5, 0, 2}, {1, 2, 0, 2},
81   {1, 2, 0, 3}, {1, 3, 0, 3},
82   {1, 5, 0, 3}, {1, 1, 0, 1},
83   {1, 5, 1, 2}, {1, 2, 1, 2},
84   {0, 3, 0, 4}, {0, 2, 0, 4},
85   {0, 1, 0, 0},
86 };
87 
88 // This is a two-colour set of 16 tiles.
89 // See: An Alternative for Wang Tiles
90 static CornerDomino periodic_set[16] = {
91 //nw ne sw se
92   {0, 0, 0, 0},
93   {1, 0, 0, 0},
94   {0, 0, 1, 0},
95   {1, 0, 1, 0},
96 
97   {0, 0, 0, 1},
98   {1, 0, 0, 1},
99   {0, 0, 1, 1},
100   {1, 0, 1, 1},
101 
102   {0, 1, 0, 0},
103   {1, 1, 0, 0},
104   {0, 1, 1, 0},
105   {1, 1, 1, 0},
106 
107   {0, 1, 0, 1},
108   {1, 1, 0, 1},
109   {0, 1, 1, 1},
110   {1, 1, 1, 1},
111 };
112 } // namespace wang
113