-
Notifications
You must be signed in to change notification settings - Fork 0
/
constants.hpp
285 lines (247 loc) · 7.25 KB
/
constants.hpp
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
#pragma once
#include <cinttypes>
#include <array>
#include <string>
#define asInt(x) static_cast<int>(x)
namespace constants
{
// Computer constants
inline const char *NAME = "SeminarEngine";
inline const char* AUTHOR = "Linus Röber";
// General chess constants
inline const int BOARD_LENGTH = 8;
inline const int SQUARES_AMOUNT = 64;
inline const int SQUARES_AMOUNT_PADDED = 120;
inline const int PIECE_TYPE_COUNT = 13;
inline const std::string FEN_START_POS = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";
// Hashing constants
inline const int RANDOM_SEED = 1234;
constexpr int INFINITE_VAL = 999999999;
constexpr int MATE = 99999998;
enum class Color
{
WHITE = 0,
BLACK = 1,
BOTH = 2
};
enum class Piece
{
EMPTY,
wP,
wN,
wB,
wR,
wQ,
wK,
bP,
bN,
bB,
bR,
bQ,
bK
};
inline const std::array<int, 13> IS_QUEEN = { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0 };
inline const std::array<int, 13> IS_ROOK = { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0 };
inline const std::array<int, 13> IS_BISHOP = { 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0 };
inline const std::array<int, 13> IS_KNIGHT = { 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 };
inline const std::array<int, 13> IS_BISHOP_QUEEN = { 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0 };
inline const std::array<int, 13> IS_ROOK_QUEEN = { 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0 };
inline const std::array<int, 13> IS_KING = { 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1 };
inline const std::array<int, 13> IS_NOT_PAWN = { 0, 0, 1, 1, 1, 1, 1, 0, 1 ,1, 1 , 1, 1 };
inline const std::array<int, 13> IS_ROOK_QUEEN_KING = {0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1 };
inline const std::array<int, 13> IS_KNIGHT_BISHOP ={ 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0 };
inline const std::array<Color, 13> PIECE_COLOR = { Color::BOTH, Color::WHITE, Color::WHITE, Color::WHITE, Color::WHITE, Color::WHITE, Color::WHITE,
Color::BLACK, Color::BLACK, Color::BLACK, Color::BLACK, Color::BLACK, Color::BLACK};
inline const std::array<int, 13> VICTIM_SCORE = { 0, 100, 200, 300, 400, 500, 600, 100, 200, 300, 400, 500, 600 };
inline const std::array<std::vector<int>, 13> PIECE_MOVEMENT = {
std::vector<int>{},
std::vector<int>{},
std::vector<int>{-8, -19, -21, -12, 8, 19, 21, 12},
std::vector<int>{-9, -11, 11, 9},
std::vector<int>{-1, -10, 1, 10},
std::vector<int>{-1, -10, 1, 10, -9, -11, 11, 9},
std::vector<int>{-1, -10, 1, 10, -9, -11, 11, 9},
std::vector<int>{},
std::vector<int>{-8, -19, -21, -12, 8, 19, 21, 12},
std::vector<int>{-9, -11, 11, 9},
std::vector<int>{-1, -10, 1, 10},
std::vector<int>{-1, -10, 1, 10, -9, -11, 11, 9},
std::vector<int>{-1, -10, 1, 10, -9, -11, 11, 9}
};
constexpr int DIR_UP = 10;
constexpr int DIR_DOWN = -10;
constexpr int DIR_LEFT = -1;
constexpr int DIR_RIGHT = 1;
constexpr int DIR_UP_LEFT = DIR_UP + DIR_LEFT;
constexpr int DIR_UP_RIGHT = DIR_UP + DIR_RIGHT;
constexpr int DIR_DOWN_LEFT = DIR_DOWN + DIR_LEFT;
constexpr int DIR_DOWN_RIGHT = DIR_DOWN + DIR_RIGHT;
inline const char* FILE_CHAR = "abcdefgh";
enum class File
{
A,
B,
C,
D,
E,
F,
G,
H,
NONE
};
inline const char* RANK_CHAR = "12345678";
enum class Rank
{
_1,
_2,
_3,
_4,
_5,
_6,
_7,
_8,
NONE
};
enum class Square
{
A1 = 21,
B1,
C1,
D1,
E1,
F1,
G1,
H1,
A2 = 31,
B2,
C2,
D2,
E2,
F2,
G2,
H2,
A3 = 41,
B3,
C3,
D3,
E3,
F3,
G3,
H3,
A4 = 51,
B4,
C4,
D4,
E4,
F4,
G4,
H4,
A5 = 61,
B5,
C5,
D5,
E5,
F5,
G5,
H5,
A6 = 71,
B6,
C6,
D6,
E6,
F6,
G6,
H6,
A7 = 81,
B7,
C7,
D7,
E7,
F7,
G7,
H7,
A8 = 91,
B8,
C8,
D8,
E8,
F8,
G8,
H8,
OFFBOARD
};
const std::array<int, 120> CASTLE_PERMISSIONS =
{
15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 13, 15, 15, 15, 12, 15, 15, 14, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 7, 15, 15, 15, 3, 15, 15, 11, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15
};
// evaluation
inline const std::array<int, 13> PIECE_VALUE = { 0, 100, 325, 325, 550, 1000, 50000, 100, 325, 325, 550, 1000, 50000 };
const std::array<int, 64> PAWN_VALUE_TABLE = {
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
10 , 10 , 0 , -10 , -10 , 0 , 10 , 10 ,
5 , 0 , 0 , 5 , 5 , 0 , 0 , 5 ,
0 , 0 , 10 , 20 , 20 , 10 , 0 , 0 ,
5 , 5 , 5 , 10 , 10 , 5 , 5 , 5 ,
10 , 10 , 10 , 20 , 20 , 10 , 10 , 10 ,
20 , 20 , 20 , 30 , 30 , 20 , 20 , 20 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0
};
const std::array<int, 64> KNIGHT_VALUE_TABLE = {
0 , -10 , 0 , 0 , 0 , 0 , -10 , 0 ,
0 , 0 , 0 , 5 , 5 , 0 , 0 , 0 ,
0 , 0 , 10 , 10 , 10 , 10 , 0 , 0 ,
0 , 0 , 10 , 20 , 20 , 10 , 5 , 0 ,
5 , 10 , 15 , 20 , 20 , 15 , 10 , 5 ,
5 , 10 , 10 , 20 , 20 , 10 , 10 , 5 ,
0 , 0 , 5 , 10 , 10 , 5 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0
};
const std::array<int, 64> BISHOP_VALUE_TABLE = {
0 , 0 , -10 , 0 , 0 , -10 , 0 , 0 ,
0 , 0 , 0 , 10 , 10 , 0 , 0 , 0 ,
0 , 0 , 10 , 15 , 15 , 10 , 0 , 0 ,
0 , 10 , 15 , 20 , 20 , 15 , 10 , 0 ,
0 , 10 , 15 , 20 , 20 , 15 , 10 , 0 ,
0 , 0 , 10 , 15 , 15 , 10 , 0 , 0 ,
0 , 0 , 0 , 10 , 10 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0
};
const std::array<int, 64> ROOK_VALUE_TABLE = {
0 , 0 , 5 , 10 , 10 , 5 , 0 , 0 ,
0 , 0 , 5 , 10 , 10 , 5 , 0 , 0 ,
0 , 0 , 5 , 10 , 10 , 5 , 0 , 0 ,
0 , 0 , 5 , 10 , 10 , 5 , 0 , 0 ,
0 , 0 , 5 , 10 , 10 , 5 , 0 , 0 ,
0 , 0 , 5 , 10 , 10 , 5 , 0 , 0 ,
25 , 25 , 25 , 25 , 25 , 25 , 25 , 25 ,
0 , 0 , 5 , 10 , 10 , 5 , 0 , 0
};
const std::array<int, 64> MIRROR_SQUARE = {
56 , 57 , 58 , 59 , 60 , 61 , 62 , 63 ,
48 , 49 , 50 , 51 , 52 , 53 , 54 , 55 ,
40 , 41 , 42 , 43 , 44 , 45 , 46 , 47 ,
32 , 33 , 34 , 35 , 36 , 37 , 38 , 39 ,
24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 ,
16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 ,
8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 ,
0 , 1 , 2 , 3 , 4 , 5 , 6 , 7
};
enum class Castle
{
wK = 1,
wQ = 2,
bK = 4,
bQ = 8
};
} // namespace constants