-
Notifications
You must be signed in to change notification settings - Fork 0
/
masks.h
executable file
·177 lines (158 loc) · 17.6 KB
/
masks.h
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
/**********************************************************************
|
| Bogart
| Chess Engine
|
| Copyright (C) 2009-2013 Dr.Kameleon
|
|**********************************************************************
| masks.h
|**********************************************************************/
#ifndef __MASKS_H__
#define __MASKS_H__
//=======================================================
// Rows, Columns & Diagonals
//=======================================================
const U64 ROW_MASK[] = {
0x00000000000000FF, 0x00000000000000FF, 0x00000000000000FF, 0x00000000000000FF, 0x00000000000000FF, 0x00000000000000FF, 0x00000000000000FF, 0x00000000000000FF,
0x000000000000FF00, 0x000000000000FF00, 0x000000000000FF00, 0x000000000000FF00, 0x000000000000FF00, 0x000000000000FF00, 0x000000000000FF00, 0x000000000000FF00,
0x0000000000FF0000, 0x0000000000FF0000, 0x0000000000FF0000, 0x0000000000FF0000, 0x0000000000FF0000, 0x0000000000FF0000, 0x0000000000FF0000, 0x0000000000FF0000,
0x00000000FF000000, 0x00000000FF000000, 0x00000000FF000000, 0x00000000FF000000, 0x00000000FF000000, 0x00000000FF000000, 0x00000000FF000000, 0x00000000FF000000,
0x000000FF00000000, 0x000000FF00000000, 0x000000FF00000000, 0x000000FF00000000, 0x000000FF00000000, 0x000000FF00000000, 0x000000FF00000000, 0x000000FF00000000,
0x0000FF0000000000, 0x0000FF0000000000, 0x0000FF0000000000, 0x0000FF0000000000, 0x0000FF0000000000, 0x0000FF0000000000, 0x0000FF0000000000, 0x0000FF0000000000,
0x00FF000000000000, 0x00FF000000000000, 0x00FF000000000000, 0x00FF000000000000, 0x00FF000000000000, 0x00FF000000000000, 0x00FF000000000000, 0x00FF000000000000,
0xFF00000000000000, 0xFF00000000000000, 0xFF00000000000000, 0xFF00000000000000, 0xFF00000000000000, 0xFF00000000000000, 0xFF00000000000000, 0xFF00000000000000
};
const U64 COL_MASK[] = {
0x0101010101010101, 0x0202020202020202, 0x0404040404040404, 0x0808080808080808, 0x1010101010101010, 0x2020202020202020, 0x4040404040404040, 0x8080808080808080,
0x0101010101010101, 0x0202020202020202, 0x0404040404040404, 0x0808080808080808, 0x1010101010101010, 0x2020202020202020, 0x4040404040404040, 0x8080808080808080,
0x0101010101010101, 0x0202020202020202, 0x0404040404040404, 0x0808080808080808, 0x1010101010101010, 0x2020202020202020, 0x4040404040404040, 0x8080808080808080,
0x0101010101010101, 0x0202020202020202, 0x0404040404040404, 0x0808080808080808, 0x1010101010101010, 0x2020202020202020, 0x4040404040404040, 0x8080808080808080,
0x0101010101010101, 0x0202020202020202, 0x0404040404040404, 0x0808080808080808, 0x1010101010101010, 0x2020202020202020, 0x4040404040404040, 0x8080808080808080,
0x0101010101010101, 0x0202020202020202, 0x0404040404040404, 0x0808080808080808, 0x1010101010101010, 0x2020202020202020, 0x4040404040404040, 0x8080808080808080,
0x0101010101010101, 0x0202020202020202, 0x0404040404040404, 0x0808080808080808, 0x1010101010101010, 0x2020202020202020, 0x4040404040404040, 0x8080808080808080,
0x0101010101010101, 0x0202020202020202, 0x0404040404040404, 0x0808080808080808, 0x1010101010101010, 0x2020202020202020, 0x4040404040404040, 0x8080808080808080
};
const U64 DIAG1_MASK[] = {
0x0000000000000001, 0x0000000000000102, 0x0000000000010204, 0x0000000001020408, 0x0000000102040810, 0x0000010204081020, 0x0001020408102040, 0x0102040810204080,
0x0000000000000102, 0x0000000000010204, 0x0000000001020408, 0x0000000102040810, 0x0000010204081020, 0x0001020408102040, 0x0102040810204080, 0x0204081020408000,
0x0000000000010204, 0x0000000001020408, 0x0000000102040810, 0x0000010204081020, 0x0001020408102040, 0x0102040810204080, 0x0204081020408000, 0x0408102040800000,
0x0000000001020408, 0x0000000102040810, 0x0000010204081020, 0x0001020408102040, 0x0102040810204080, 0x0204081020408000, 0x0408102040800000, 0x0810204080000000,
0x0000000102040810, 0x0000010204081020, 0x0001020408102040, 0x0102040810204080, 0x0204081020408000, 0x0408102040800000, 0x0810204080000000, 0x1020408000000000,
0x0000010204081020, 0x0001020408102040, 0x0102040810204080, 0x0204081020408000, 0x0408102040800000, 0x0810204080000000, 0x1020408000000000, 0x2040800000000000,
0x0001020408102040, 0x0102040810204080, 0x0204081020408000, 0x0408102040800000, 0x0810204080000000, 0x1020408000000000, 0x2040800000000000, 0x4080000000000000,
0x0102040810204080, 0x0204081020408000, 0x0408102040800000, 0x0810204080000000, 0x1020408000000000, 0x2040800000000000, 0x4080000000000000, 0x8000000000000000
};
const U64 DIAG2_MASK[] = {
0x8040201008040201, 0x0080402010080402, 0x0000804020100804, 0x0000008040201008, 0x0000000080402010, 0x0000000000804020, 0x0000000000008040, 0x0000000000000080,
0x4020100804020100, 0x8040201008040201, 0x0080402010080402, 0x0000804020100804, 0x0000008040201008, 0x0000000080402010, 0x0000000000804020, 0x0000000000008040,
0x2010080402010000, 0x4020100804020100, 0x8040201008040201, 0x0080402010080402, 0x0000804020100804, 0x0000008040201008, 0x0000000080402010, 0x0000000000804020,
0x1008040201000000, 0x2010080402010000, 0x4020100804020100, 0x8040201008040201, 0x0080402010080402, 0x0000804020100804, 0x0000008040201008, 0x0000000080402010,
0x0804020100000000, 0x1008040201000000, 0x2010080402010000, 0x4020100804020100, 0x8040201008040201, 0x0080402010080402, 0x0000804020100804, 0x0000008040201008,
0x0402010000000000, 0x0804020100000000, 0x1008040201000000, 0x2010080402010000, 0x4020100804020100, 0x8040201008040201, 0x0080402010080402, 0x0000804020100804,
0x0201000000000000, 0x0402010000000000, 0x0804020100000000, 0x1008040201000000, 0x2010080402010000, 0x4020100804020100, 0x8040201008040201, 0x0080402010080402,
0x0100000000000000, 0x0201000000000000, 0x0402010000000000, 0x0804020100000000, 0x1008040201000000, 0x2010080402010000, 0x4020100804020100, 0x8040201008040201
};
//=======================================================
// Castling Masks
//=======================================================
const U64 CASTLE_MASK[] = {
0x0600000000000000ULL,
0x7000000000000000ULL,
0x0000000000000006ULL,
0x0000000000000070ULL
};
//=======================================================
// Piece Movement (on an empty board)
//=======================================================
const U64 ROOK_MASK[64] = {
0x01010101010101FF, 0x02020202020202FF, 0x04040404040404FF, 0x08080808080808FF, 0x10101010101010FF, 0x20202020202020FF, 0x40404040404040FF, 0x80808080808080FF,
0x010101010101FF01, 0x020202020202FF02, 0x040404040404FF04, 0x080808080808FF08, 0x101010101010FF10, 0x202020202020FF20, 0x404040404040FF40, 0x808080808080FF80,
0x0101010101FF0101, 0x0202020202FF0202, 0x0404040404FF0404, 0x0808080808FF0808, 0x1010101010FF1010, 0x2020202020FF2020, 0x4040404040FF4040, 0x8080808080FF8080,
0x01010101FF010101, 0x02020202FF020202, 0x04040404FF040404, 0x08080808FF080808, 0x10101010FF101010, 0x20202020FF202020, 0x40404040FF404040, 0x80808080FF808080,
0x010101FF01010101, 0x020202FF02020202, 0x040404FF04040404, 0x080808FF08080808, 0x101010FF10101010, 0x202020FF20202020, 0x404040FF40404040, 0x808080FF80808080,
0x0101FF0101010101, 0x0202FF0202020202, 0x0404FF0404040404, 0x0808FF0808080808, 0x1010FF1010101010, 0x2020FF2020202020, 0x4040FF4040404040, 0x8080FF8080808080,
0x01FF010101010101, 0x02FF020202020202, 0x04FF040404040404, 0x08FF080808080808, 0x10FF101010101010, 0x20FF202020202020, 0x40FF404040404040, 0x80FF808080808080,
0xFF01010101010101, 0xFF02020202020202, 0xFF04040404040404, 0xFF08080808080808, 0xFF10101010101010, 0xFF20202020202020, 0xFF40404040404040, 0xFF80808080808080
};
const U64 KNIGHT_MASK[64] = {
0x0000000000020400, 0x0000000000050800, 0x00000000000A1100, 0x0000000000142200, 0x0000000000284400, 0x0000000000508800, 0x0000000000A01000, 0x0000000000402000,
0x0000000002040004, 0x0000000005080008, 0x000000000A110011, 0x0000000014220022, 0x0000000028440044, 0x0000000050880088, 0x00000000A0100010, 0x0000000040200020,
0x0000000204000402, 0x0000000508000805, 0x0000000A1100110A, 0x0000001422002214, 0x0000002844004428, 0x0000005088008850, 0x000000A0100010A0, 0x0000004020002040,
0x0000020400040200, 0x0000050800080500, 0x00000A1100110A00, 0x0000142200221400, 0x0000284400442800, 0x0000508800885000, 0x0000A0100010A000, 0x0000402000204000,
0x0002040004020000, 0x0005080008050000, 0x000A1100110A0000, 0x0014220022140000, 0x0028440044280000, 0x0050880088500000, 0x00A0100010A00000, 0x0040200020400000,
0x0204000402000000, 0x0508000805000000, 0x0A1100110A000000, 0x1422002214000000, 0x2844004428000000, 0x5088008850000000, 0xA0100010A0000000, 0x4020002040000000,
0x0400040200000000, 0x0800080500000000, 0x1100110A00000000, 0x2200221400000000, 0x4400442800000000, 0x8800885000000000, 0x100010A000000000, 0x2000204000000000,
0x0004020000000000, 0x0008050000000000, 0x00110A0000000000, 0x0022140000000000, 0x0044280000000000, 0x0088500000000000, 0x0010A00000000000, 0x0020400000000000
};
const U64 BISHOP_MASK[64] = {
0x8040201008040201, 0x0080402010080502, 0x0000804020110A04, 0x0000008041221408, 0x0000000182442810, 0x0000010204885020, 0x000102040810A040, 0x0102040810204080,
0x4020100804020102, 0x8040201008050205, 0x00804020110A040A, 0x0000804122140814, 0x0000018244281028, 0x0001020488502050, 0x0102040810A040A0, 0x0204081020408040,
0x2010080402010204, 0x4020100805020508, 0x804020110A040A11, 0x0080412214081422, 0x0001824428102844, 0x0102048850205088, 0x02040810A040A010, 0x0408102040804020,
0x1008040201020408, 0x2010080502050810, 0x4020110A040A1120, 0x8041221408142241, 0x0182442810284482, 0x0204885020508804, 0x040810A040A01008, 0x0810204080402010,
0x0804020102040810, 0x1008050205081020, 0x20110A040A112040, 0x4122140814224180, 0x8244281028448201, 0x0488502050880402, 0x0810A040A0100804, 0x1020408040201008,
0x0402010204081020, 0x0805020508102040, 0x110A040A11204080, 0x2214081422418000, 0x4428102844820100, 0x8850205088040201, 0x10A040A010080402, 0x2040804020100804,
0x0201020408102040, 0x0502050810204080, 0x0A040A1120408000, 0x1408142241800000, 0x2810284482010000, 0x5020508804020100, 0xA040A01008040201, 0x4080402010080402,
0x0102040810204080, 0x0205081020408000, 0x040A112040800000, 0x0814224180000000, 0x1028448201000000, 0x2050880402010000, 0x40A0100804020100, 0x8040201008040201
};
const U64 QUEEN_MASK[64] = {
0x81412111090503FF, 0x02824222120A07FF, 0x0404844424150EFF, 0x08080888492A1CFF, 0x10101011925438FF, 0x2020212224A870FF, 0x404142444850E0FF, 0x8182848890A0C0FF,
0x412111090503FF03, 0x824222120A07FF07, 0x04844424150EFF0E, 0x080888492A1CFF1C, 0x101011925438FF38, 0x20212224A870FF70, 0x4142444850E0FFE0, 0x82848890A0C0FFC0,
0x2111090503FF0305, 0x4222120A07FF070A, 0x844424150EFF0E15, 0x0888492A1CFF1C2A, 0x1011925438FF3854, 0x212224A870FF70A8, 0x42444850E0FFE050, 0x848890A0C0FFC0A0,
0x11090503FF030509, 0x22120A07FF070A12, 0x4424150EFF0E1524, 0x88492A1CFF1C2A49, 0x11925438FF385492, 0x2224A870FF70A824, 0x444850E0FFE05048, 0x8890A0C0FFC0A090,
0x090503FF03050911, 0x120A07FF070A1222, 0x24150EFF0E152444, 0x492A1CFF1C2A4988, 0x925438FF38549211, 0x24A870FF70A82422, 0x4850E0FFE0504844, 0x90A0C0FFC0A09088,
0x0503FF0305091121, 0x0A07FF070A122242, 0x150EFF0E15244484, 0x2A1CFF1C2A498808, 0x5438FF3854921110, 0xA870FF70A8242221, 0x50E0FFE050484442, 0xA0C0FFC0A0908884,
0x03FF030509112141, 0x07FF070A12224282, 0x0EFF0E1524448404, 0x1CFF1C2A49880808, 0x38FF385492111010, 0x70FF70A824222120, 0xE0FFE05048444241, 0xC0FFC0A090888482,
0xFF03050911214181, 0xFF070A1222428202, 0xFF0E152444840404, 0xFF1C2A4988080808, 0xFF38549211101010, 0xFF70A82422212020, 0xFFE0504844424140, 0xFFC0A09088848281
};
const U64 KING_MASK[64] = {
0x0000000000000302, 0x0000000000000705, 0x0000000000000E0A, 0x0000000000001C14, 0x0000000000003828, 0x0000000000007050, 0x000000000000E0A0, 0x000000000000C040,
0x0000000000030203, 0x0000000000070507, 0x00000000000E0A0E, 0x00000000001C141C, 0x0000000000382838, 0x0000000000705070, 0x0000000000E0A0E0, 0x0000000000C040C0,
0x0000000003020300, 0x0000000007050700, 0x000000000E0A0E00, 0x000000001C141C00, 0x0000000038283800, 0x0000000070507000, 0x00000000E0A0E000, 0x00000000C040C000,
0x0000000302030000, 0x0000000705070000, 0x0000000E0A0E0000, 0x0000001C141C0000, 0x0000003828380000, 0x0000007050700000, 0x000000E0A0E00000, 0x000000C040C00000,
0x0000030203000000, 0x0000070507000000, 0x00000E0A0E000000, 0x00001C141C000000, 0x0000382838000000, 0x0000705070000000, 0x0000E0A0E0000000, 0x0000C040C0000000,
0x0003020300000000, 0x0007050700000000, 0x000E0A0E00000000, 0x001C141C00000000, 0x0038283800000000, 0x0070507000000000, 0x00E0A0E000000000, 0x00C040C000000000,
0x0302030000000000, 0x0705070000000000, 0x0E0A0E0000000000, 0x1C141C0000000000, 0x3828380000000000, 0x7050700000000000, 0xE0A0E00000000000, 0xC040C00000000000,
0x0203000000000000, 0x0507000000000000, 0x0A0E000000000000, 0x141C000000000000, 0x2838000000000000, 0x5070000000000000, 0xA0E0000000000000, 0x40C0000000000000
};
const U64 WPAWN_MASK[64] = {
0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000,
0x0000000001010000, 0x0000000002020000, 0x0000000004040000, 0x0000000008080000, 0x0000000010100000, 0x0000000020200000, 0x0000000040400000, 0x0000000080800000,
0x0000000001000000, 0x0000000002000000, 0x0000000004000000, 0x0000000008000000, 0x0000000010000000, 0x0000000020000000, 0x0000000040000000, 0x0000000080000000,
0x0000000100000000, 0x0000000200000000, 0x0000000400000000, 0x0000000800000000, 0x0000001000000000, 0x0000002000000000, 0x0000004000000000, 0x0000008000000000,
0x0000010000000000, 0x0000020000000000, 0x0000040000000000, 0x0000080000000000, 0x0000100000000000, 0x0000200000000000, 0x0000400000000000, 0x0000800000000000,
0x0001000000000000, 0x0002000000000000, 0x0004000000000000, 0x0008000000000000, 0x0010000000000000, 0x0020000000000000, 0x0040000000000000, 0x0080000000000000,
0x0100000000000000, 0x0200000000000000, 0x0400000000000000, 0x0800000000000000, 0x1000000000000000, 0x2000000000000000, 0x4000000000000000, 0x8000000000000000,
0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000
};
const U64 BPAWN_MASK[64] = {
0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000,
0x0000000000000001, 0x0000000000000002, 0x0000000000000004, 0x0000000000000008, 0x0000000000000010, 0x0000000000000020, 0x0000000000000040, 0x0000000000000080,
0x0000000000000100, 0x0000000000000200, 0x0000000000000400, 0x0000000000000800, 0x0000000000001000, 0x0000000000002000, 0x0000000000004000, 0x0000000000008000,
0x0000000000010000, 0x0000000000020000, 0x0000000000040000, 0x0000000000080000, 0x0000000000100000, 0x0000000000200000, 0x0000000000400000, 0x0000000000800000,
0x0000000001000000, 0x0000000002000000, 0x0000000004000000, 0x0000000008000000, 0x0000000010000000, 0x0000000020000000, 0x0000000040000000, 0x0000000080000000,
0x0000000100000000, 0x0000000200000000, 0x0000000400000000, 0x0000000800000000, 0x0000001000000000, 0x0000002000000000, 0x0000004000000000, 0x0000008000000000,
0x0000010100000000, 0x0000020200000000, 0x0000040400000000, 0x0000080800000000, 0x0000101000000000, 0x0000202000000000, 0x0000404000000000, 0x0000808000000000,
0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000
};
const U64 WPAWN_ATTACKMASK[64] = {
0x0000000000000200, 0x0000000000000500, 0x0000000000000A00, 0x0000000000001400, 0x0000000000002800, 0x0000000000005000, 0x000000000000A000, 0x0000000000004000,
0x0000000000020000, 0x0000000000050000, 0x00000000000A0000, 0x0000000000140000, 0x0000000000280000, 0x0000000000500000, 0x0000000000A00000, 0x0000000000400000,
0x0000000002000000, 0x0000000005000000, 0x000000000A000000, 0x0000000014000000, 0x0000000028000000, 0x0000000050000000, 0x00000000A0000000, 0x0000000040000000,
0x0000000200000000, 0x0000000500000000, 0x0000000A00000000, 0x0000001400000000, 0x0000002800000000, 0x0000005000000000, 0x000000A000000000, 0x0000004000000000,
0x0000020000000000, 0x0000050000000000, 0x00000A0000000000, 0x0000140000000000, 0x0000280000000000, 0x0000500000000000, 0x0000A00000000000, 0x0000400000000000,
0x0002000000000000, 0x0005000000000000, 0x000A000000000000, 0x0014000000000000, 0x0028000000000000, 0x0050000000000000, 0x00A0000000000000, 0x0040000000000000,
0x0200000000000000, 0x0500000000000000, 0x0A00000000000000, 0x1400000000000000, 0x2800000000000000, 0x5000000000000000, 0xA000000000000000, 0x4000000000000000,
0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000
};
const U64 BPAWN_ATTACKMASK[64] = {
0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000,
0x0000000000000002, 0x0000000000000005, 0x000000000000000A, 0x0000000000000014, 0x0000000000000028, 0x0000000000000050, 0x00000000000000A0, 0x0000000000000040,
0x0000000000000200, 0x0000000000000500, 0x0000000000000A00, 0x0000000000001400, 0x0000000000002800, 0x0000000000005000, 0x000000000000A000, 0x0000000000004000,
0x0000000000020000, 0x0000000000050000, 0x00000000000A0000, 0x0000000000140000, 0x0000000000280000, 0x0000000000500000, 0x0000000000A00000, 0x0000000000400000,
0x0000000002000000, 0x0000000005000000, 0x000000000A000000, 0x0000000014000000, 0x0000000028000000, 0x0000000050000000, 0x00000000A0000000, 0x0000000040000000,
0x0000000200000000, 0x0000000500000000, 0x0000000A00000000, 0x0000001400000000, 0x0000002800000000, 0x0000005000000000, 0x000000A000000000, 0x0000004000000000,
0x0000020000000000, 0x0000050000000000, 0x00000A0000000000, 0x0000140000000000, 0x0000280000000000, 0x0000500000000000, 0x0000A00000000000, 0x0000400000000000,
0x0002000000000000, 0x0005000000000000, 0x000A000000000000, 0x0014000000000000, 0x0028000000000000, 0x0050000000000000, 0x00A0000000000000, 0x0040000000000000
};
#endif