-
Notifications
You must be signed in to change notification settings - Fork 1
/
presetPositions.py
293 lines (265 loc) · 5.16 KB
/
presetPositions.py
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
286
287
288
289
290
291
292
293
"""
@author: Foo Zhi Yuan
ChessAI is being implemented using the concepts of bitboard and principal variation search
Requires Python 3 and Pillow(for GUI)
USAGE: python chessAI.py to play in GUI and python chessAI_console.py to play in console
"""
"""
10000000
10000000
10000000
10000000
10000000
10000000
10000000
10000000
"""
LEFTCOLONE=72340172838076673 #File_A
"""
00000001
00000001
00000001
00000001
00000001
00000001
00000001
00000001
"""
RIGHTCOLONE=9259542123273814144 #File_H
"""
11000000
11000000
11000000
11000000
11000000
11000000
11000000
11000000
"""
LEFTTWOCOLONE=217020518514230019 #File_AB
"""
00000011
00000011
00000011
00000011
00000011
00000011
00000011
00000011
"""
RIGHTTWOCOLONE=13889313184910721216 #File_GH
"""
11110000
11110000
11110000
11110000
11110000
11110000
11110000
11110000
"""
LEFTFOURCOLONE=1085102592571150095 #Queen_side
""""
00001111
00001111
00001111
00001111
00001111
00001111
00001111
00001111
"""
RIGHTFOURCOLONE=17361641481138401520 #King_side
"""
11111111
00000000
00000000
00000000
00000000
00000000
00000000
00000000
"""
ROWZEROONE=255 #Rank_8
"""
00000000
00000000
00000000
11111111
00000000
00000000
00000000
00000000
"""
ROWTHREEONE=4278190080 #Rank_5
"""
00000000
00000000
00000000
00000000
11111111
00000000
00000000
00000000
"""
ROWFOURONE=1095216660480 #Rank_4
"""
00000000
00000000
00000000
00000000
00000000
00000000
00000000
11111111
"""
ROWSEVENONE=18374686479671623680 #Rank_1
"""
00000000
00000000
00000000
00011000
00011000
00000000
00000000
00000000
"""
CENTERFOURONE=103481868288 #center
"""
00000000
00000000
00111100
00111100
00111100
00111100
00000000
00000000
"""
CENTERSIXTEENONE=66229406269440 #extended_center
#Positions that king at (1,1) can capture
"""
11100000
10100000
11100000
00000000
00000000
00000000
00000000
00000000
"""
KING_1_1=460039 #king_b7
#Positions that knight at (2,2) can capture
"""
01010000
10001000
00H00000
10001000
01010000
00000000
00000000
00000000
"""
KNIGHT_2_2=43234889994 #knight_span
#moves that are involved in white queen side castling
"""
00000000
00000000
00000000
00000000
00000000
00000000
00000000
01110000
"""
WHITE_QUEENSIDEMOVES=1008806316530991104
#moves that are involved in white king side castling
"""
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000110
"""
WHITE_KINGSIDEMOVES=6917529027641081856
#moves that are involved in black queen side castling
"""
01110000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
"""
BLACK_QUEENSIDEMOVES=14
#moves that are involved in black king side castling
"""
00000110
00000000
00000000
00000000
00000000
00000000
00000000
00000000
"""
BLACK_KINGSIDEMOVES=96
#SPECIAL
#moves that are involved in flipped white king side castling
"""
00000000
00000000
00000000
00000000
00000000
00000000
00000000
01100000
"""
FLIPPED_WHITE_KINGSIDEMOVES=432345564227567616
#moves that are involved in flipped white queen side castling
"""
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00001110
"""
FLIPPED_WHITE_QUEENSIDEMOVES=8070450532247928832
#RowMask
ROWALLONE={0:255,1:65280,2:16711680,3:4278190080,4:1095216660480,5:280375465082880,6:71776119061217280,7:18374686479671623680}
#FileMask
COLALLONE={0:72340172838076673,1:144680345676153346,2:289360691352306692,3:578721382704613384,4:1157442765409226768,5:2314885530818453536,6:4629771061636907072,7:9259542123273814144}
#AntiDiagonalMask
#from top left corner to bottom right corner
"""
00000001 00001000 10000000 00000000 00000000
00000000 00000100 01000000 00000000 00000000
00000000 00000010 00100000 10000000 00000000
00000000 -> ... -> 00000001 -> ... -> 00010000 -> ... -> 01000000 ->...-> 00000000
00000000 00000000 00001000 00100000 00000000
00000000 00000000 00000100 00010000 10000000
00000000 00000000 00000010 00001000 01000000
00000000 00000000 00000001 00000100 00100000
"""
LEFTDIAGONAL={0:128,1:32832,2:8405024,3:2151686160,4:550831656968,5:141012904183812,6:36099303471055874,7:9241421688590303745,8:4620710844295151872,9:2310355422147575808,10:1155177711073755136,11:577588855528488960,12:288794425616760832,13:144396663052566528,14:72057594037927936}
#DiagonalMask
#from top right corner to bottom left corner
"""
10000000 00010000 00000001 00000000 00000000
00000000 00100000 00000010 00000000 00000000
00000000 01000000 00000100 00000001 00000000
00000000 -> ... -> 10000000 -> ... -> 00001000 -> ... -> 00000010 ->...-> 00000000
00000000 00000000 00010000 00000100 00000000
00000000 00000000 00100000 00001000 00000001
00000000 00000000 01000000 00010000 00000010
00000000 00000000 10000000 00100000 00000100
"""
RIGHTDIAGONAL={0:1,1:258,2:66052,3:16909320,4:4328785936,5:1108169199648,6:283691315109952,7:72624976668147840,8:145249953336295424,9:290499906672525312,10:580999813328273408,11:1161999622361579520,12:2323998145211531264,13:4647714815446351872,14:9223372036854775808}