Knight's Tour Generator
Tourneys and the Fast Generation and Obfuscation of Closed Knight's Tours
Tile.cpp
Go to the documentation of this file.
1 
4 // MIT License
5 //
6 // Copyright (c) 2019 Ian Parberry
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to
10 // deal in the Software without restriction, including without limitation the
11 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 // sell copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in
16 // all copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 // IN THE SOFTWARE.
25 
26 #include "Tile.h"
27 
29 // Hard-coded CTile move tables
30 
31 int CTile::m_nTile6x6[36] = {
32  13, 12, 6, 11, 8, 9,
33  14, 3, 0, 22, 2, 15,
34  25, 21, 1, 23, 5, 4,
35  7, 32, 28, 10, 35, 34,
36  20, 33, 30, 31, 17, 16,
37  19, 18, 24, 29, 26, 27
38 }; //6x6
39 
40 int CTile::m_nTile8x6[48] = {
41  10, 11, 8, 9, 14, 20, 12, 13,
42  18, 24, 25, 21, 2, 3, 31, 5,
43  1, 0, 35, 4, 37, 15, 7, 6,
44  41, 40, 32, 17, 43, 44, 36, 46,
45  42, 16, 28, 45, 19, 47, 23, 22,
46  34, 26, 27, 33, 38, 39, 29, 30
47 }; //8x6;
48 
49 int CTile::m_nTile6x8[48]{
50  13, 14, 6, 11, 17, 16,
51  19, 3, 0, 5, 2, 15,
52  1, 9, 22, 4, 27, 21,
53  7, 32, 24, 8, 35, 10,
54  37, 12, 34, 23, 20, 40,
55  26, 18, 43, 29, 47, 46,
56  25, 45, 42, 28, 44, 33,
57  31, 30, 36, 41, 38, 39
58 }; //6x8
59 
60 int CTile::m_nTile8x8[64] = {
61  10, 18, 8, 13, 21, 11, 23, 22,
62  25, 3, 4, 26, 6, 7, 31, 5,
63  1, 0, 24, 2, 37, 15, 39, 38,
64  9, 42, 43, 12, 34, 14, 20, 46,
65  17, 16, 40, 45, 19, 27, 55, 29,
66  57, 58, 52, 28, 54, 62, 63, 30,
67  33, 32, 56, 36, 35, 59, 60, 61,
68  41, 51, 48, 49, 50, 44, 47, 53
69 }; //8x8
70 
71 int CTile::m_nTile10x8[80] = {
72  12, 13, 10, 15, 16, 24, 14, 19, 29, 28,
73  22, 3, 4, 5, 2, 7, 8, 9, 6, 38,
74  1, 0, 41, 42, 36, 37, 47, 46, 49, 17,
75  11, 23, 20, 52, 26, 56, 48, 45, 59, 18,
76  21, 60, 50, 35, 25, 33, 54, 39, 27, 68,
77  71, 30, 31, 32, 75, 34, 44, 69, 66, 78,
78  72, 40, 70, 55, 43, 73, 74, 79, 76, 77,
79  51, 63, 53, 61, 62, 67, 64, 65, 57, 58
80 }; //10x8
81 
82 int CTile::m_nTile8x10[80]{
83  17, 18, 8, 9, 10, 15, 23, 13,
84  25, 24, 0, 26, 6, 3, 4, 30,
85  1, 32, 12, 2, 5, 11, 7, 29,
86  41, 40, 20, 21, 43, 19, 45, 14,
87  49, 16, 51, 50, 42, 47, 28, 22,
88  34, 56, 59, 53, 27, 35, 31, 62,
89  33, 64, 60, 68, 37, 36, 39, 38,
90  73, 72, 52, 44, 75, 78, 79, 46,
91  74, 48, 76, 77, 58, 54, 55, 61,
92  66, 67, 57, 65, 70, 71, 63, 69
93 }; //8x10
94 
95 int CTile::m_nTile10x10[100] = {
96  21, 20, 10, 15, 12, 13, 14, 19, 16, 17,
97  22, 23, 0, 1, 35, 7, 4, 29, 37, 38,
98  32, 40, 3, 2, 5, 44, 45, 6, 9, 8,
99  11, 50, 51, 25, 46, 47, 24, 56, 59, 18,
100  61, 62, 30, 55, 63, 66, 27, 26, 36, 28,
101  42, 70, 31, 41, 33, 34, 75, 65, 39, 67,
102  52, 80, 54, 71, 43, 73, 74, 48, 49, 77,
103  91, 90, 93, 81, 53, 83, 57, 58, 97, 87,
104  92, 60, 94, 95, 96, 64, 98, 99, 69, 68,
105  82, 72, 84, 85, 86, 76, 88, 89, 79, 78
106 }; //10x10
107 
108 int CTile::m_nTile10x12[120]{
109  21, 20, 10, 11, 25, 13, 14, 26, 16, 17,
110  31, 30, 0, 1, 22, 36, 4, 29, 37, 7,
111  12, 2, 3, 35, 32, 6, 5, 15, 9, 8,
112  51, 50, 40, 41, 46, 27, 48, 45, 19, 18,
113  52, 60, 61, 24, 23, 66, 65, 55, 56, 28,
114  71, 70, 33, 34, 73, 74, 77, 49, 39, 38,
115  72, 53, 54, 42, 43, 44, 47, 75, 87, 57,
116  91, 90, 80, 81, 62, 94, 84, 89, 59, 58,
117  101, 93, 63, 64, 105, 97, 67, 95, 69, 68,
118  111, 110, 100, 85, 82, 83, 117, 76, 79, 78,
119  112, 113, 114, 115, 116, 86, 118, 119, 96, 88,
120  102, 103, 104, 92, 106, 107, 108, 109, 99, 98
121 }; //10x12
122 
123 int CTile::m_nTile12x10[120] = {
124  14, 15, 25, 17, 29, 19, 31, 21, 22, 23, 35, 34,
125  2, 3, 24, 5, 6, 7, 41, 9, 45, 11, 47, 46,
126  1, 0, 36, 4, 18, 39, 53, 8, 42, 10, 59, 58,
127  13, 12, 63, 16, 50, 51, 28, 20, 54, 68, 71, 33,
128  62, 26, 27, 76, 38, 43, 40, 30, 70, 32, 83, 82,
129  37, 75, 72, 86, 78, 55, 52, 57, 93, 44, 80, 94,
130  49, 48, 60, 100, 66, 91, 88, 56, 90, 95, 107, 106,
131  74, 110, 61, 64, 65, 112, 67, 116, 69, 79, 119, 118,
132  73, 87, 108, 109, 77, 111, 92, 113, 114, 115, 81, 117,
133  85, 84, 96, 97, 98, 99, 89, 101, 102, 103, 104, 105
134 }; //12x10
135 
137 // CTile constructor and destructor
138 
140 
142  m_pTile6x6 = new CBoard(m_nTile6x6, 6, 6);
143  m_pTile6x8 = new CBoard(m_nTile6x8, 6, 8);
144 
145  m_pTile8x6 = new CBoard(m_nTile8x6, 8, 6);
146  m_pTile8x8 = new CBoard(m_nTile8x8, 8, 8);
147  m_pTile8x10 = new CBoard(m_nTile8x10, 8, 10);
148 
149  m_pTile10x8 = new CBoard(m_nTile10x8, 10, 8);
150  m_pTile10x10 = new CBoard(m_nTile10x10, 10, 10);
151  m_pTile10x12 = new CBoard(m_nTile10x12, 10, 12);
152 
153  m_pTile12x10 = new CBoard(m_nTile12x10, 12, 10);
154 } //constructor
155 
157 
159  delete m_pTile6x6;
160  delete m_pTile8x6;
161  delete m_pTile6x8;
162  delete m_pTile8x8;
163  delete m_pTile10x8;
164  delete m_pTile8x10;
165  delete m_pTile10x10;
166  delete m_pTile10x12;
167  delete m_pTile12x10;
168 } //destructor
Header for CTile.
CBoard * m_pTile8x8
Pointer to an 8x8 chessboard.
Definition: Tile.h:61
CBoard * m_pTile8x10
Pointer to an 8x10 chessboard.
Definition: Tile.h:62
static int m_nTile8x8[64]
8x8 move table.
Definition: Tile.h:47
static int m_nTile10x12[120]
10x12 move table.
Definition: Tile.h:52
CBoard * m_pTile8x6
Pointer to an 8x6 chessboard.
Definition: Tile.h:60
static int m_nTile12x10[120]
12x10 move table.
Definition: Tile.h:54
static int m_nTile10x8[80]
10x8 move table.
Definition: Tile.h:50
CBoard * m_pTile6x8
Pointer to a 6x8 chessboard.
Definition: Tile.h:58
static int m_nTile10x10[100]
10x10 move table.
Definition: Tile.h:51
static int m_nTile8x10[80]
8x10 move table.
Definition: Tile.h:48
Chessboard.
Definition: Board.h:42
CBoard * m_pTile10x12
Pointer to a 10x12 chessboard.
Definition: Tile.h:66
CTile()
Constructor.
Definition: Tile.cpp:141
CBoard * m_pTile6x6
Pointer to a 6x6 chessboard.
Definition: Tile.h:57
CBoard * m_pTile10x8
Pointer to a 10x8 chessboard.
Definition: Tile.h:64
~CTile()
Destructor.
Definition: Tile.cpp:158
static int m_nTile8x6[48]
8x6 move table.
Definition: Tile.h:46
static int m_nTile6x6[36]
6x6 move table.
Definition: Tile.h:43
CBoard * m_pTile12x10
Pointer to a 12x10 chessboard.
Definition: Tile.h:68
static int m_nTile6x8[48]
6x8 move table.
Definition: Tile.h:44
CBoard * m_pTile10x10
Pointer to a 10x10 chessboard.
Definition: Tile.h:65