Rev 108 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
33 | pmbaty | 1 | #include "chess.h" |
2 | /* *INDENT-OFF* */#if !defined(INLINEASM) |
||
3 | unsigned char msb[65536]; |
||
4 | unsigned char lsb[65536]; |
||
5 | #endif |
||
6 | unsigned char msb_8bit[256]; |
||
7 | unsigned char lsb_8bit[256]; |
||
8 | unsigned char pop_cnt_8bit[256]; |
||
9 | unsigned char is_outside[256][256]; |
||
10 | uint64_t mask_pawn_connected[64]; |
||
11 | uint64_t mask_pawn_isolated[64]; |
||
12 | uint64_t mask_passed[2][64]; |
||
13 | uint64_t mask_no_pattacks[2][64]; |
||
14 | uint64_t mask_hidden_left[2][8]; |
||
15 | uint64_t mask_hidden_right[2][8]; |
||
16 | uint64_t pawn_race[2][2][64]; |
||
17 | BOOK_POSITION book_buffer[BOOK_CLUSTER_SIZE]; |
||
18 | BOOK_POSITION book_buffer_char[BOOK_CLUSTER_SIZE]; |
||
19 | int OOsqs[2][3] = {{ E8, F8, G8 }, { E1, F1, G1 }}; |
||
20 | int OOOsqs[2][3] = {{ E8, D8, C8 }, { E1, D1, C1 }}; |
||
21 | int OOfrom[2] = { E8, E1 }; |
||
22 | int OOto[2] = { G8, G1 }; |
||
23 | int OOOto[2] = { C8, C1 }; |
||
24 | #define VERSION "24.0" |
||
25 | char version[8] = { VERSION }; |
||
26 | PLAYING_MODE mode = normal_mode; |
||
27 | int batch_mode = 0; /* no asynch reads */ |
||
28 | int swindle_mode = 1; /* try to swindle */ |
||
29 | int call_flag = 0; |
||
30 | int crafty_rating = 2500; |
||
31 | int opponent_rating = 2500; |
||
32 | int last_search_value = 0; |
||
33 | int pruning_margin[10] = {0, 100, 100, 200, 200, 300, 300, 400}; |
||
34 | int pruning_depth = 6; |
||
35 | int pgn_suggested_percent = 0; |
||
36 | char pgn_event[128] = { "?" }; |
||
37 | char pgn_site[128] = { "?" }; |
||
38 | char pgn_date[128] = { "????.??.??" }; |
||
39 | char pgn_round[128] = { "?" }; |
||
40 | char pgn_white[128] = { "unknown" }; |
||
41 | char pgn_white_elo[128] = { "" }; |
||
42 | char pgn_black[128] = { "Crafty " VERSION }; |
||
43 | char pgn_black_elo[128] = { "" }; |
||
44 | char pgn_result[128] = { "*" }; |
||
45 | char *B_list[128]; |
||
46 | char *AK_list[128]; |
||
47 | char *GM_list[128]; |
||
48 | char *IM_list[128]; |
||
49 | char *SP_list[128]; |
||
50 | char *SP_opening_filename[128]; |
||
51 | char *SP_personality_filename[128]; |
||
52 | int output_format = 0; |
||
53 | #if !defined(NOEGTB) |
||
54 | int EGTBlimit = 0; |
||
55 | int EGTB_use = 0; |
||
56 | int EGTB_draw = 0; |
||
57 | int EGTB_search = 0; |
||
58 | size_t EGTB_cache_size = 4096 * 4096; |
||
59 | void *EGTB_cache = (void *) 0; |
||
60 | int EGTB_setup = 0; |
||
61 | #endif |
||
62 | int xboard = 0; |
||
63 | int pong = 0; |
||
64 | int early_exit = 99; |
||
65 | int new_game = 0; |
||
66 | char book_path[128] = { BOOKDIR }; |
||
67 | char log_path[128] = { LOGDIR }; |
||
68 | char tb_path[128] = { TBDIR }; |
||
69 | char rc_path[128] = { RCDIR }; |
||
70 | int initialized = 0; |
||
71 | int kibitz = 0; |
||
72 | int post = 0; |
||
73 | int log_id = 0; |
||
74 | int game_wtm = 1; |
||
75 | int last_opponent_move = 0; |
||
76 | int check_depth = 1; |
||
77 | int null_depth = 3; /* R=3 */ |
||
78 | int LMR_remaining_depth = 1; /* leave 1 full ply after reductions */ |
||
79 | int LMR_min_reduction = 1; /* minimum reduction 1 ply */ |
||
80 | int LMR_max_reduction = 2; /* maximum reduction 2 plies */ |
||
81 | int search_depth = 0; |
||
82 | /*uint64_t*/ unsigned int search_nodes = 0; // Pierre-Marie Baty -- fixed type |
||
83 | /*uint64_t*/ unsigned int temp_search_nodes = 0; // Pierre-Marie Baty -- fixed type |
||
84 | int search_move = 0; |
||
85 | int predicted = 0; |
||
86 | int time_used = 0; |
||
87 | int time_used_opponent = 0; |
||
88 | int analyze_mode = 0; |
||
89 | int annotate_mode = 0; |
||
90 | int input_status = 0; |
||
91 | int resign = 9; |
||
92 | int resign_counter = 0; |
||
93 | int resign_count = 5; |
||
94 | int draw_counter = 0; |
||
95 | int draw_count = 5; |
||
96 | int draw_offer_pending = 0; |
||
97 | int draw_offered = 0; |
||
98 | int offer_draws = 1; |
||
99 | int adaptive_hash = 0; |
||
100 | size_t adaptive_hash_min = 0; |
||
101 | size_t adaptive_hash_max = 0; |
||
102 | size_t adaptive_hashp_min = 0; |
||
103 | size_t adaptive_hashp_max = 0; |
||
104 | int time_limit = 100; |
||
105 | int force = 0; |
||
106 | char initial_position[80] = { "" }; |
||
107 | char hint[512] = { "" }; |
||
108 | char book_hint[512] = { "" }; |
||
109 | int over = 0; |
||
110 | int usage_level = 0; |
||
111 | char audible_alarm = 0x07; |
||
112 | char speech = 0; |
||
113 | int book_accept_mask = ~03; |
||
114 | int book_reject_mask = 3; |
||
115 | int book_random = 1; |
||
116 | float book_weight_learn = 1.0; |
||
117 | float book_weight_freq = 1.0; |
||
118 | float book_weight_eval = 0.1f; // Pierre-Marie Baty -- added float suffix |
||
119 | int book_search_trigger = 20; |
||
120 | int learn = 1; |
||
121 | int learning = 100; |
||
122 | int learn_value = 0; |
||
123 | int abort_search; /* 1 = abort / print stats, 2 = abort no print stats */ |
||
124 | int iteration_depth; |
||
125 | int root_wtm; |
||
126 | int root_beta; |
||
127 | int last_root_value; |
||
128 | ROOT_MOVE root_moves[256]; |
||
129 | int n_root_moves; |
||
130 | int difficulty; |
||
131 | int absolute_time_limit; |
||
132 | int search_time_limit; |
||
133 | int burp; |
||
134 | int quit = 0; |
||
135 | unsigned int opponent_start_time, opponent_end_time; |
||
136 | unsigned int program_start_time, program_end_time; |
||
137 | unsigned int start_time, end_time; |
||
138 | TREE *block[MAX_BLOCKS + 1]; |
||
139 | THREAD thread[CPUS]; |
||
140 | #if (CPUS > 1) |
||
141 | lock_t lock_split, lock_smp, lock_io, lock_root; |
||
142 | #if defined(UNIX) |
||
143 | pthread_attr_t attributes; |
||
144 | #endif |
||
145 | #endif |
||
146 | int smp_max_threads = 0; |
||
147 | int smp_split_group = 5; /* max threads per group - 1 */ |
||
148 | int smp_split_at_root = 1; |
||
149 | int smp_min_split_depth = 5; |
||
150 | unsigned int smp_split_nodes = 2000; |
||
151 | unsigned int parallel_splits; |
||
152 | unsigned int parallel_aborts; |
||
153 | unsigned int idle_time; |
||
154 | unsigned int max_split_blocks = 0; |
||
155 | unsigned int idle_percent = 0; |
||
156 | volatile int smp_idle = 0; |
||
157 | volatile int smp_split = 0; |
||
158 | volatile int smp_threads = 0; |
||
159 | volatile int initialized_threads = 0; |
||
160 | int crafty_is_white = 0; |
||
161 | unsigned int nodes_between_time_checks = 1000000; |
||
162 | unsigned int nodes_per_second = 1000000; |
||
163 | int next_time_check = 100000; |
||
164 | int transposition_age = 0; |
||
165 | int thinking = 0; |
||
166 | int pondering = 0; |
||
167 | int puzzling = 0; |
||
168 | int booking = 0; |
||
169 | int display_options = 4095 - 256 - 512; |
||
170 | unsigned int noise_level = 200000; |
||
171 | int noise_block = 0; |
||
172 | int tc_moves = 60; |
||
173 | int tc_time = 180000; |
||
174 | int tc_time_remaining[2] = { 180000, 180000 }; |
||
175 | int tc_moves_remaining[2] = { 60, 60 }; |
||
176 | int tc_secondary_moves = 30; |
||
177 | int tc_secondary_time = 90000; |
||
178 | int tc_increment = 0; |
||
179 | int tc_sudden_death = 0; |
||
180 | int tc_operator_time = 0; |
||
181 | int tc_safety_margin = 0; |
||
182 | int draw_score[2] = { 0, 0 }; |
||
183 | char kibitz_text[4096]; |
||
184 | int kibitz_depth; |
||
185 | int move_number = 1; |
||
186 | int moves_out_of_book = 0; |
||
187 | int first_nonbook_factor = 0; |
||
188 | int first_nonbook_span = 0; |
||
189 | int smp_nice = 1; |
||
190 | #if defined(SKILL) |
||
191 | int skill = 100; |
||
192 | #endif |
||
193 | int show_book = 0; |
||
194 | int book_selection_width = 5; |
||
195 | int ponder = 1; |
||
196 | int trace_level = 0; |
||
197 | /* for the following 6 lines, each pair should have */ |
||
198 | /* the same numeric value (the size value). */ |
||
199 | size_t hash_table_size = 524288; |
||
200 | uint64_t hash_mask = (524288 -1) & ~3; |
||
201 | size_t hash_path_size = 65536; |
||
202 | uint64_t hash_path_mask = (65536 - 1) & ~15; |
||
203 | size_t pawn_hash_table_size = 16384; |
||
204 | uint64_t pawn_hash_mask = 16384 - 1; |
||
205 | int abs_draw_score = 1; |
||
206 | int accept_draws = 1; |
||
207 | const char translate[13] = |
||
208 | { 'k', 'q', 'r', 'b', 'n', 'p', 0, 'P', 'N', 'B', 'R', 'Q', 'K' }; |
||
209 | int16_t knight_mobility_table[64]; |
||
210 | uint64_t magic_bishop[64] = { |
||
211 | 0x0002020202020200ull, 0x0002020202020000ull, 0x0004010202000000ull, |
||
212 | 0x0004040080000000ull, 0x0001104000000000ull, 0x0000821040000000ull, |
||
213 | 0x0000410410400000ull, 0x0000104104104000ull, 0x0000040404040400ull, |
||
214 | 0x0000020202020200ull, 0x0000040102020000ull, 0x0000040400800000ull, |
||
215 | 0x0000011040000000ull, 0x0000008210400000ull, 0x0000004104104000ull, |
||
216 | 0x0000002082082000ull, 0x0004000808080800ull, 0x0002000404040400ull, |
||
217 | 0x0001000202020200ull, 0x0000800802004000ull, 0x0000800400A00000ull, |
||
218 | 0x0000200100884000ull, 0x0000400082082000ull, 0x0000200041041000ull, |
||
219 | 0x0002080010101000ull, 0x0001040008080800ull, 0x0000208004010400ull, |
||
220 | 0x0000404004010200ull, 0x0000840000802000ull, 0x0000404002011000ull, |
||
221 | 0x0000808001041000ull, 0x0000404000820800ull, 0x0001041000202000ull, |
||
222 | 0x0000820800101000ull, 0x0000104400080800ull, 0x0000020080080080ull, |
||
223 | 0x0000404040040100ull, 0x0000808100020100ull, 0x0001010100020800ull, |
||
224 | 0x0000808080010400ull, 0x0000820820004000ull, 0x0000410410002000ull, |
||
225 | 0x0000082088001000ull, 0x0000002011000800ull, 0x0000080100400400ull, |
||
226 | 0x0001010101000200ull, 0x0002020202000400ull, 0x0001010101000200ull, |
||
227 | 0x0000410410400000ull, 0x0000208208200000ull, 0x0000002084100000ull, |
||
228 | 0x0000000020880000ull, 0x0000001002020000ull, 0x0000040408020000ull, |
||
229 | 0x0004040404040000ull, 0x0002020202020000ull, 0x0000104104104000ull, |
||
230 | 0x0000002082082000ull, 0x0000000020841000ull, 0x0000000000208800ull, |
||
231 | 0x0000000010020200ull, 0x0000000404080200ull, 0x0000040404040400ull, |
||
232 | 0x0002020202020200ull |
||
233 | }; |
||
234 | uint64_t magic_bishop_mask[64] = { |
||
235 | 0x0040201008040200ull, 0x0000402010080400ull, 0x0000004020100A00ull, |
||
236 | 0x0000000040221400ull, 0x0000000002442800ull, 0x0000000204085000ull, |
||
237 | 0x0000020408102000ull, 0x0002040810204000ull, 0x0020100804020000ull, |
||
238 | 0x0040201008040000ull, 0x00004020100A0000ull, 0x0000004022140000ull, |
||
239 | 0x0000000244280000ull, 0x0000020408500000ull, 0x0002040810200000ull, |
||
240 | 0x0004081020400000ull, 0x0010080402000200ull, 0x0020100804000400ull, |
||
241 | 0x004020100A000A00ull, 0x0000402214001400ull, 0x0000024428002800ull, |
||
242 | 0x0002040850005000ull, 0x0004081020002000ull, 0x0008102040004000ull, |
||
243 | 0x0008040200020400ull, 0x0010080400040800ull, 0x0020100A000A1000ull, |
||
244 | 0x0040221400142200ull, 0x0002442800284400ull, 0x0004085000500800ull, |
||
245 | 0x0008102000201000ull, 0x0010204000402000ull, 0x0004020002040800ull, |
||
246 | 0x0008040004081000ull, 0x00100A000A102000ull, 0x0022140014224000ull, |
||
247 | 0x0044280028440200ull, 0x0008500050080400ull, 0x0010200020100800ull, |
||
248 | 0x0020400040201000ull, 0x0002000204081000ull, 0x0004000408102000ull, |
||
249 | 0x000A000A10204000ull, 0x0014001422400000ull, 0x0028002844020000ull, |
||
250 | 0x0050005008040200ull, 0x0020002010080400ull, 0x0040004020100800ull, |
||
251 | 0x0000020408102000ull, 0x0000040810204000ull, 0x00000A1020400000ull, |
||
252 | 0x0000142240000000ull, 0x0000284402000000ull, 0x0000500804020000ull, |
||
253 | 0x0000201008040200ull, 0x0000402010080400ull, 0x0002040810204000ull, |
||
254 | 0x0004081020400000ull, 0x000A102040000000ull, 0x0014224000000000ull, |
||
255 | 0x0028440200000000ull, 0x0050080402000000ull, 0x0020100804020000ull, |
||
256 | 0x0040201008040200ull |
||
257 | }; |
||
258 | unsigned int magic_bishop_shift[64] = { |
||
259 | 58, 59, 59, 59, 59, 59, 59, 58, |
||
260 | 59, 59, 59, 59, 59, 59, 59, 59, |
||
261 | 59, 59, 57, 57, 57, 57, 59, 59, |
||
262 | 59, 59, 57, 55, 55, 57, 59, 59, |
||
263 | 59, 59, 57, 55, 55, 57, 59, 59, |
||
264 | 59, 59, 57, 57, 57, 57, 59, 59, |
||
265 | 59, 59, 59, 59, 59, 59, 59, 59, |
||
266 | 58, 59, 59, 59, 59, 59, 59, 58 |
||
267 | }; |
||
268 | uint64_t magic_bishop_table[5248]; |
||
269 | uint64_t *magic_bishop_indices[64] = { |
||
270 | magic_bishop_table + 4992, magic_bishop_table + 2624, |
||
271 | magic_bishop_table + 256, magic_bishop_table + 896, |
||
272 | magic_bishop_table + 1280, magic_bishop_table + 1664, |
||
273 | magic_bishop_table + 4800, magic_bishop_table + 5120, |
||
274 | magic_bishop_table + 2560, magic_bishop_table + 2656, |
||
275 | magic_bishop_table + 288, magic_bishop_table + 928, |
||
276 | magic_bishop_table + 1312, magic_bishop_table + 1696, |
||
277 | magic_bishop_table + 4832, magic_bishop_table + 4928, |
||
278 | magic_bishop_table + 0, magic_bishop_table + 128, |
||
279 | magic_bishop_table + 320, magic_bishop_table + 960, |
||
280 | magic_bishop_table + 1344, magic_bishop_table + 1728, |
||
281 | magic_bishop_table + 2304, magic_bishop_table + 2432, |
||
282 | magic_bishop_table + 32, magic_bishop_table + 160, |
||
283 | magic_bishop_table + 448, magic_bishop_table + 2752, |
||
284 | magic_bishop_table + 3776, magic_bishop_table + 1856, |
||
285 | magic_bishop_table + 2336, magic_bishop_table + 2464, |
||
286 | magic_bishop_table + 64, magic_bishop_table + 192, |
||
287 | magic_bishop_table + 576, magic_bishop_table + 3264, |
||
288 | magic_bishop_table + 4288, magic_bishop_table + 1984, |
||
289 | magic_bishop_table + 2368, magic_bishop_table + 2496, |
||
290 | magic_bishop_table + 96, magic_bishop_table + 224, |
||
291 | magic_bishop_table + 704, magic_bishop_table + 1088, |
||
292 | magic_bishop_table + 1472, magic_bishop_table + 2112, |
||
293 | magic_bishop_table + 2400, magic_bishop_table + 2528, |
||
294 | magic_bishop_table + 2592, magic_bishop_table + 2688, |
||
295 | magic_bishop_table + 832, magic_bishop_table + 1216, |
||
296 | magic_bishop_table + 1600, magic_bishop_table + 2240, |
||
297 | magic_bishop_table + 4864, magic_bishop_table + 4960, |
||
298 | magic_bishop_table + 5056, magic_bishop_table + 2720, |
||
299 | magic_bishop_table + 864, magic_bishop_table + 1248, |
||
300 | magic_bishop_table + 1632, magic_bishop_table + 2272, |
||
301 | magic_bishop_table + 4896, magic_bishop_table + 5184 |
||
302 | }; |
||
303 | int16_t magic_bishop_mobility_table[5248]; |
||
304 | int16_t *magic_bishop_mobility_indices[64] = { |
||
305 | magic_bishop_mobility_table + 4992, magic_bishop_mobility_table + 2624, |
||
306 | magic_bishop_mobility_table + 256, magic_bishop_mobility_table + 896, |
||
307 | magic_bishop_mobility_table + 1280, magic_bishop_mobility_table + 1664, |
||
308 | magic_bishop_mobility_table + 4800, magic_bishop_mobility_table + 5120, |
||
309 | magic_bishop_mobility_table + 2560, magic_bishop_mobility_table + 2656, |
||
310 | magic_bishop_mobility_table + 288, magic_bishop_mobility_table + 928, |
||
311 | magic_bishop_mobility_table + 1312, magic_bishop_mobility_table + 1696, |
||
312 | magic_bishop_mobility_table + 4832, magic_bishop_mobility_table + 4928, |
||
313 | magic_bishop_mobility_table + 0, magic_bishop_mobility_table + 128, |
||
314 | magic_bishop_mobility_table + 320, magic_bishop_mobility_table + 960, |
||
315 | magic_bishop_mobility_table + 1344, magic_bishop_mobility_table + 1728, |
||
316 | magic_bishop_mobility_table + 2304, magic_bishop_mobility_table + 2432, |
||
317 | magic_bishop_mobility_table + 32, magic_bishop_mobility_table + 160, |
||
318 | magic_bishop_mobility_table + 448, magic_bishop_mobility_table + 2752, |
||
319 | magic_bishop_mobility_table + 3776, magic_bishop_mobility_table + 1856, |
||
320 | magic_bishop_mobility_table + 2336, magic_bishop_mobility_table + 2464, |
||
321 | magic_bishop_mobility_table + 64, magic_bishop_mobility_table + 192, |
||
322 | magic_bishop_mobility_table + 576, magic_bishop_mobility_table + 3264, |
||
323 | magic_bishop_mobility_table + 4288, magic_bishop_mobility_table + 1984, |
||
324 | magic_bishop_mobility_table + 2368, magic_bishop_mobility_table + 2496, |
||
325 | magic_bishop_mobility_table + 96, magic_bishop_mobility_table + 224, |
||
326 | magic_bishop_mobility_table + 704, magic_bishop_mobility_table + 1088, |
||
327 | magic_bishop_mobility_table + 1472, magic_bishop_mobility_table + 2112, |
||
328 | magic_bishop_mobility_table + 2400, magic_bishop_mobility_table + 2528, |
||
329 | magic_bishop_mobility_table + 2592, magic_bishop_mobility_table + 2688, |
||
330 | magic_bishop_mobility_table + 832, magic_bishop_mobility_table + 1216, |
||
331 | magic_bishop_mobility_table + 1600, magic_bishop_mobility_table + 2240, |
||
332 | magic_bishop_mobility_table + 4864, magic_bishop_mobility_table + 4960, |
||
333 | magic_bishop_mobility_table + 5056, magic_bishop_mobility_table + 2720, |
||
334 | magic_bishop_mobility_table + 864, magic_bishop_mobility_table + 1248, |
||
335 | magic_bishop_mobility_table + 1632, magic_bishop_mobility_table + 2272, |
||
336 | magic_bishop_mobility_table + 4896, magic_bishop_mobility_table + 5184 |
||
337 | }; |
||
338 | uint64_t magic_rook_table[102400]; |
||
339 | uint64_t *magic_rook_indices[64] = { |
||
340 | magic_rook_table + 86016, magic_rook_table + 73728, |
||
341 | magic_rook_table + 36864, magic_rook_table + 43008, |
||
342 | magic_rook_table + 47104, magic_rook_table + 51200, |
||
343 | magic_rook_table + 77824, magic_rook_table + 94208, |
||
344 | magic_rook_table + 69632, magic_rook_table + 32768, |
||
345 | magic_rook_table + 38912, magic_rook_table + 10240, |
||
346 | magic_rook_table + 14336, magic_rook_table + 53248, |
||
347 | magic_rook_table + 57344, magic_rook_table + 81920, |
||
348 | magic_rook_table + 24576, magic_rook_table + 33792, |
||
349 | magic_rook_table + 6144, magic_rook_table + 11264, |
||
350 | magic_rook_table + 15360, magic_rook_table + 18432, |
||
351 | magic_rook_table + 58368, magic_rook_table + 61440, |
||
352 | magic_rook_table + 26624, magic_rook_table + 4096, |
||
353 | magic_rook_table + 7168, magic_rook_table + 0, |
||
354 | magic_rook_table + 2048, magic_rook_table + 19456, |
||
355 | magic_rook_table + 22528, magic_rook_table + 63488, |
||
356 | magic_rook_table + 28672, magic_rook_table + 5120, |
||
357 | magic_rook_table + 8192, magic_rook_table + 1024, |
||
358 | magic_rook_table + 3072, magic_rook_table + 20480, |
||
359 | magic_rook_table + 23552, magic_rook_table + 65536, |
||
360 | magic_rook_table + 30720, magic_rook_table + 34816, |
||
361 | magic_rook_table + 9216, magic_rook_table + 12288, |
||
362 | magic_rook_table + 16384, magic_rook_table + 21504, |
||
363 | magic_rook_table + 59392, magic_rook_table + 67584, |
||
364 | magic_rook_table + 71680, magic_rook_table + 35840, |
||
365 | magic_rook_table + 39936, magic_rook_table + 13312, |
||
366 | magic_rook_table + 17408, magic_rook_table + 54272, |
||
367 | magic_rook_table + 60416, magic_rook_table + 83968, |
||
368 | magic_rook_table + 90112, magic_rook_table + 75776, |
||
369 | magic_rook_table + 40960, magic_rook_table + 45056, |
||
370 | magic_rook_table + 49152, magic_rook_table + 55296, |
||
371 | magic_rook_table + 79872, magic_rook_table + 98304 |
||
372 | }; |
||
373 | int16_t magic_rook_mobility_table[102400]; |
||
374 | int16_t *magic_rook_mobility_indices[64] = { |
||
375 | magic_rook_mobility_table + 86016, magic_rook_mobility_table + 73728, |
||
376 | magic_rook_mobility_table + 36864, magic_rook_mobility_table + 43008, |
||
377 | magic_rook_mobility_table + 47104, magic_rook_mobility_table + 51200, |
||
378 | |||
379 | magic_rook_mobility_table + 69632, magic_rook_mobility_table + 32768, |
||
380 | magic_rook_mobility_table + 38912, magic_rook_mobility_table + 10240, |
||
381 | magic_rook_mobility_table + 14336, magic_rook_mobility_table + 53248, |
||
382 | magic_rook_mobility_table + 57344, magic_rook_mobility_table + 81920, |
||
383 | magic_rook_mobility_table + 24576, magic_rook_mobility_table + 33792, |
||
384 | magic_rook_mobility_table + 6144, magic_rook_mobility_table + 11264, |
||
385 | magic_rook_mobility_table + 15360, magic_rook_mobility_table + 18432, |
||
386 | magic_rook_mobility_table + 58368, magic_rook_mobility_table + 61440, |
||
387 | magic_rook_mobility_table + 26624, magic_rook_mobility_table + 4096, |
||
388 | magic_rook_mobility_table + 7168, magic_rook_mobility_table + 0, |
||
389 | magic_rook_mobility_table + 2048, magic_rook_mobility_table + 19456, |
||
390 | magic_rook_mobility_table + 22528, magic_rook_mobility_table + 63488, |
||
391 | magic_rook_mobility_table + 28672, magic_rook_mobility_table + 5120, |
||
392 | magic_rook_mobility_table + 8192, magic_rook_mobility_table + 1024, |
||
393 | magic_rook_mobility_table + 3072, magic_rook_mobility_table + 20480, |
||
394 | magic_rook_mobility_table + 23552, magic_rook_mobility_table + 65536, |
||
395 | magic_rook_mobility_table + 30720, magic_rook_mobility_table + 34816, |
||
396 | magic_rook_mobility_table + 9216, magic_rook_mobility_table + 12288, |
||
397 | magic_rook_mobility_table + 16384, magic_rook_mobility_table + 21504, |
||
398 | magic_rook_mobility_table + 59392, magic_rook_mobility_table + 67584, |
||
399 | magic_rook_mobility_table + 71680, magic_rook_mobility_table + 35840, |
||
400 | magic_rook_mobility_table + 39936, magic_rook_mobility_table + 13312, |
||
401 | magic_rook_mobility_table + 17408, magic_rook_mobility_table + 54272, |
||
402 | magic_rook_mobility_table + 60416, magic_rook_mobility_table + 83968, |
||
403 | magic_rook_mobility_table + 90112, magic_rook_mobility_table + 75776, |
||
404 | magic_rook_mobility_table + 40960, magic_rook_mobility_table + 45056, |
||
405 | magic_rook_mobility_table + 49152, magic_rook_mobility_table + 55296, |
||
406 | magic_rook_mobility_table + 79872, magic_rook_mobility_table + 98304 |
||
407 | }; |
||
408 | uint64_t magic_rook[64] = { |
||
409 | 0x0080001020400080ull, 0x0040001000200040ull, 0x0080081000200080ull, |
||
410 | 0x0080040800100080ull, 0x0080020400080080ull, 0x0080010200040080ull, |
||
411 | 0x0080008001000200ull, 0x0080002040800100ull, 0x0000800020400080ull, |
||
412 | 0x0000400020005000ull, 0x0000801000200080ull, 0x0000800800100080ull, |
||
413 | 0x0000800400080080ull, 0x0000800200040080ull, 0x0000800100020080ull, |
||
414 | 0x0000800040800100ull, 0x0000208000400080ull, 0x0000404000201000ull, |
||
415 | 0x0000808010002000ull, 0x0000808008001000ull, 0x0000808004000800ull, |
||
416 | 0x0000808002000400ull, 0x0000010100020004ull, 0x0000020000408104ull, |
||
417 | 0x0000208080004000ull, 0x0000200040005000ull, 0x0000100080200080ull, |
||
418 | 0x0000080080100080ull, 0x0000040080080080ull, 0x0000020080040080ull, |
||
419 | 0x0000010080800200ull, 0x0000800080004100ull, 0x0000204000800080ull, |
||
420 | 0x0000200040401000ull, 0x0000100080802000ull, 0x0000080080801000ull, |
||
421 | 0x0000040080800800ull, 0x0000020080800400ull, 0x0000020001010004ull, |
||
422 | 0x0000800040800100ull, 0x0000204000808000ull, 0x0000200040008080ull, |
||
423 | 0x0000100020008080ull, 0x0000080010008080ull, 0x0000040008008080ull, |
||
424 | 0x0000020004008080ull, 0x0000010002008080ull, 0x0000004081020004ull, |
||
425 | 0x0000204000800080ull, 0x0000200040008080ull, 0x0000100020008080ull, |
||
426 | 0x0000080010008080ull, 0x0000040008008080ull, 0x0000020004008080ull, |
||
427 | 0x0000800100020080ull, 0x0000800041000080ull, 0x00FFFCDDFCED714Aull, |
||
428 | 0x007FFCDDFCED714Aull, 0x003FFFCDFFD88096ull, 0x0000040810002101ull, |
||
429 | 0x0001000204080011ull, 0x0001000204000801ull, 0x0001000082000401ull, |
||
430 | 0x0001FFFAABFAD1A2ull |
||
431 | }; |
||
432 | uint64_t magic_rook_mask[64] = { |
||
433 | 0x000101010101017Eull, 0x000202020202027Cull, 0x000404040404047Aull, |
||
434 | 0x0008080808080876ull, 0x001010101010106Eull, 0x002020202020205Eull, |
||
435 | 0x004040404040403Eull, 0x008080808080807Eull, 0x0001010101017E00ull, |
||
436 | 0x0002020202027C00ull, 0x0004040404047A00ull, 0x0008080808087600ull, |
||
437 | 0x0010101010106E00ull, 0x0020202020205E00ull, 0x0040404040403E00ull, |
||
438 | 0x0080808080807E00ull, 0x00010101017E0100ull, 0x00020202027C0200ull, |
||
439 | 0x00040404047A0400ull, 0x0008080808760800ull, 0x00101010106E1000ull, |
||
440 | 0x00202020205E2000ull, 0x00404040403E4000ull, 0x00808080807E8000ull, |
||
441 | 0x000101017E010100ull, 0x000202027C020200ull, 0x000404047A040400ull, |
||
442 | 0x0008080876080800ull, 0x001010106E101000ull, 0x002020205E202000ull, |
||
443 | 0x004040403E404000ull, 0x008080807E808000ull, 0x0001017E01010100ull, |
||
444 | 0x0002027C02020200ull, 0x0004047A04040400ull, 0x0008087608080800ull, |
||
445 | 0x0010106E10101000ull, 0x0020205E20202000ull, 0x0040403E40404000ull, |
||
446 | 0x0080807E80808000ull, 0x00017E0101010100ull, 0x00027C0202020200ull, |
||
447 | 0x00047A0404040400ull, 0x0008760808080800ull, 0x00106E1010101000ull, |
||
448 | 0x00205E2020202000ull, 0x00403E4040404000ull, 0x00807E8080808000ull, |
||
449 | 0x007E010101010100ull, 0x007C020202020200ull, 0x007A040404040400ull, |
||
450 | 0x0076080808080800ull, 0x006E101010101000ull, 0x005E202020202000ull, |
||
451 | 0x003E404040404000ull, 0x007E808080808000ull, 0x7E01010101010100ull, |
||
452 | 0x7C02020202020200ull, 0x7A04040404040400ull, 0x7608080808080800ull, |
||
453 | 0x6E10101010101000ull, 0x5E20202020202000ull, 0x3E40404040404000ull, |
||
454 | 0x7E80808080808000ull |
||
455 | }; |
||
456 | unsigned int magic_rook_shift[64] = { |
||
457 | 52, 53, 53, 53, 53, 53, 53, 52, |
||
458 | 53, 54, 54, 54, 54, 54, 54, 53, |
||
459 | 53, 54, 54, 54, 54, 54, 54, 53, |
||
460 | 53, 54, 54, 54, 54, 54, 54, 53, |
||
461 | 53, 54, 54, 54, 54, 54, 54, 53, |
||
462 | 53, 54, 54, 54, 54, 54, 54, 53, |
||
463 | 53, 54, 54, 54, 54, 54, 54, 53, |
||
464 | 53, 54, 54, 53, 53, 53, 53, 53 |
||
465 | }; |
||
466 | uint64_t mobility_mask_n[4] = { |
||
467 | 0xFF818181818181FFull, 0x007E424242427E00ull, |
||
468 | 0x00003C24243C0000ull, 0x0000001818000000ull |
||
469 | }; |
||
470 | uint64_t mobility_mask_b[4] = { |
||
471 | 0xFF818181818181FFull, 0x007E424242427E00ull, |
||
472 | 0x00003C24243C0000ull, 0x0000001818000000ull |
||
473 | }; |
||
474 | uint64_t mobility_mask_r[4] = { |
||
475 | 0x8181818181818181ull, 0x4242424242424242ull, |
||
476 | 0x2424242424242424ull, 0x1818181818181818ull |
||
477 | }; |
||
478 | /* |
||
479 | values use to deal with white/black independently |
||
480 | */ |
||
481 | const int rankflip[2][8] = { |
||
482 | { RANK8, RANK7, RANK6, RANK5, RANK4, RANK3, RANK2, RANK1 }, |
||
483 | { RANK1, RANK2, RANK3, RANK4, RANK5, RANK6, RANK7, RANK8 } |
||
484 | }; |
||
485 | const int sqflip[2][64] = { |
||
486 | { A8, B8, C8, D8, E8, F8, G8, H8, |
||
487 | A7, B7, C7, D7, E7, F7, G7, H7, |
||
488 | A6, B6, C6, D6, E6, F6, G6, H6, |
||
489 | A5, B5, C5, D5, E5, F5, G5, H5, |
||
490 | A4, B4, C4, D4, E4, F4, G4, H4, /* black */ |
||
491 | A3, B3, C3, D3, E3, F3, G3, H3, |
||
492 | A2, B2, C2, D2, E2, F2, G2, H2, |
||
493 | A1, B1, C1, D1, E1, F1, G1, H1 }, |
||
494 | |||
495 | { A1, B1, C1, D1, E1, F1, G1, H1, |
||
496 | A2, B2, C2, D2, E2, F2, G2, H2, |
||
497 | A3, B3, C3, D3, E3, F3, G3, H3, |
||
498 | A4, B4, C4, D4, E4, F4, G4, H4, |
||
499 | A5, B5, C5, D5, E5, F5, G5, H5, /* white */ |
||
500 | A6, B6, C6, D6, E6, F6, G6, H6, |
||
501 | A7, B7, C7, D7, E7, F7, G7, H7, |
||
502 | A8, B8, C8, D8, E8, F8, G8, H8 } |
||
503 | }; |
||
504 | const int sign[2] = { -1, 1 }; |
||
505 | int direction[2] = { -8, 8 }; |
||
506 | int dark_corner[2] = { FILEA, FILEH }; |
||
507 | int light_corner[2] = { FILEH, FILEA }; |
||
508 | int epsq[2] = { +8, -8 }; |
||
509 | int rook_A[2] = { A8, A1 }; |
||
510 | int rook_D[2] = { D8, D1 }; |
||
511 | int rook_F[2] = { F8, F1 }; |
||
512 | int rook_G[2] = { G8, G1 }; |
||
513 | int rook_H[2] = { H8, H1 }; |
||
514 | int pawnadv1[2] = { +8, -8 }; |
||
515 | int pawnadv2[2] = { +16, -16 }; |
||
516 | int capleft[2] = { +9, -7 }; |
||
517 | int capright[2] = { +7, -9 }; |
||
518 | const char empty_sqs[9] = { 0, '1', '2', '3', '4', '5', '6', '7', '8' }; |
||
519 | /* |
||
520 | This array is indexed by rook advantage and minor piece advantage. |
||
521 | rook advantage is 4 + white rook equivalents - black rook equivalents |
||
522 | where a rook equivalent is number of rooks + 2 * number of queens. |
||
523 | minor piece advantage is 4 + white minors - black minors. |
||
524 | |||
525 | The classic bad trade case is two minors for a rook. If white trades |
||
526 | two minors for a rook, rook advantage is +5 and minor advantage is +2. |
||
527 | imbalance[5][2] gives a penalty of -42 for this trade. |
||
528 | */ |
||
529 | int imbalance[9][9] = { |
||
530 | /* M=-4 M=-3 M=-2 M=-1 M=0 M=+1 M=+2 M=+3 M=+4 */ |
||
531 | {-126, -126, -126, -126, -126, -126, -126, -126, -42 }, /* R=-4 */ |
||
532 | {-126, -126, -126, -126, -126, -126, -126, -42, 42 }, /* R=-3 */ |
||
533 | {-126, -126, -126, -126, -126, -126, -42, 84, 84 }, /* R=-2 */ |
||
534 | {-126, -126, -126, -126, -104, -42, 84, 126, 126 }, /* R=-1 */ |
||
535 | {-126, -126, -126, -88, 0, 88, 126, 126, 126 }, /* R=0 */ |
||
536 | {-126, -126, -84, 42, 104, 126, 126, 126, 126 }, /* R=+1 */ |
||
537 | { -84, -84, 42, 126, 126, 126, 126, 126, 126 }, /* R=+2 */ |
||
538 | { -42, 42, 126, 126, 126, 126, 126, 126, 126 }, /* R=+3 */ |
||
539 | { 42, 126, 126, 126, 126, 126, 126, 126, 126 } /* R=+4 */ |
||
540 | }; |
||
541 | int pp_dist_bonus[8] = { 0, 0, 0, 2, 7, 19, 31, 0 }; |
||
542 | int king_tropism_n[8] = { 0, 3, 3, 2, 1, 0, 0, 0 }; |
||
543 | int king_tropism_b[8] = { 0, 2, 2, 1, 0, 0, 0, 0 }; |
||
544 | int king_tropism_r[8] = { 0, 4, 3, 2, 1, 1, 1, 1 }; |
||
545 | int king_tropism_q[8] = { 0, 6, 5, 4, 3, 2, 2, 2 }; |
||
546 | int passed_pawn_value[2][8] = { |
||
547 | { 0, 6, 6, 30, 70, 120, 200, 0 }, /* [mg][8] */ |
||
548 | { 0, 7, 7, 33, 77, 132, 220, 0 } /* [eg][8] */ |
||
549 | }; |
||
550 | int passed_pawn_connected[2][8] = { |
||
551 | { 0, 1, 1, 3, 7, 12, 20, 0 }, /* [mg][8] */ |
||
552 | { 0, 2, 2, 9, 21, 36, 60, 0 } /* [eg][8] */ |
||
553 | }; |
||
554 | int rook_behind_passed_pawn[2][8] = { |
||
555 | { 0, 1, 1, 3, 7, 12, 20, 0 }, /* [mg][8] */ |
||
556 | { 0, 2, 2, 9, 21, 36, 60, 0 } /* [eg][8] */ |
||
557 | }; |
||
558 | int passed_pawn_blockaded_by_enemy[2][8] = { |
||
559 | { 0, 3, 3, 14, 33, 57, 95, 0 }, /* [mg][8] */ |
||
560 | { 0, 2, 2, 11, 25, 42, 70, 0 } /* [eg][8] */ |
||
561 | }; |
||
562 | int passed_pawn_blockaded_by_friendly[2][8] = { |
||
563 | { 0, 1, 1, 7, 16, 27, 45, 0 }, /* [mg][8] */ |
||
564 | { 0, 1, 1, 3, 7, 12, 20, 0 } /* [eg][8] */ |
||
565 | }; |
||
566 | int passed_pawn_obstructed[8] = { 0, 1, 1, 4, 9, 15, 25, 0 }; |
||
567 | int passed_pawn_far_away[8] = { 0, 1, 1, 6, 14, 24, 40, 0 }; |
||
568 | int passed_pawn_not_far_away[8] = { 0, 1, 1, 4, 9, 15, 25, 0 }; |
||
569 | int passed_pawn_candidate[2][8] = { |
||
570 | { 0, 4, 4, 8, 16, 36, 0, 0 }, /* [mg][rank] */ |
||
571 | { 0, 9, 9, 16, 32, 48, 0, 0 } /* [eg][rank] */ |
||
572 | }; |
||
573 | int passed_pawn_hidden[2] = { 0, 40 }; |
||
574 | int doubled_pawn_value[2] = { 5, 6 }; |
||
575 | int outside_passed[2] = { 20, 60 }; |
||
576 | int pawn_defects[2][8] = { |
||
577 | { 0, 0, 0, 1, 2, 3, 0, 0 }, /* [black][8] */ |
||
578 | { 0, 0, 3, 2, 1, 0, 0, 0 } /* [white][8] */ |
||
579 | }; |
||
580 | const char square_color[64] = { |
||
581 | 1, 0, 1, 0, 1, 0, 1, 0, |
||
582 | 0, 1, 0, 1, 0, 1, 0, 1, |
||
583 | 1, 0, 1, 0, 1, 0, 1, 0, |
||
584 | 0, 1, 0, 1, 0, 1, 0, 1, |
||
585 | 1, 0, 1, 0, 1, 0, 1, 0, |
||
586 | 0, 1, 0, 1, 0, 1, 0, 1, |
||
587 | 1, 0, 1, 0, 1, 0, 1, 0, |
||
588 | 0, 1, 0, 1, 0, 1, 0, 1 |
||
589 | }; |
||
590 | const char b_n_mate_dark_squares[64] = { |
||
591 | 99, 90, 80, 70, 60, 50, 40, 30, |
||
592 | 90, 80, 70, 60, 50, 40, 30, 40, |
||
593 | 80, 70, 60, 50, 40, 30, 40, 50, |
||
594 | 70, 60, 50, 40, 30, 40, 50, 60, |
||
595 | 60, 50, 40, 30, 40, 50, 60, 70, |
||
596 | 50, 40, 30, 40, 50, 60, 70, 80, |
||
597 | 40, 30, 40, 50, 60, 70, 80, 90, |
||
598 | 30, 40, 50, 60, 70, 80, 90, 99 |
||
599 | }; |
||
600 | const char b_n_mate_light_squares[64] = { |
||
601 | 30, 40, 50, 60, 70, 80, 90, 99, |
||
602 | 40, 30, 40, 50, 60, 70, 80, 90, |
||
603 | 50, 40, 30, 40, 50, 60, 70, 80, |
||
604 | 60, 50, 40, 30, 40, 50, 60, 70, |
||
605 | 70, 60, 50, 40, 30, 40, 50, 60, |
||
606 | 80, 70, 60, 50, 40, 30, 40, 50, |
||
607 | 90, 80, 70, 60, 50, 40, 30, 40, |
||
608 | 99, 90, 80, 70, 60, 50, 40, 30 |
||
609 | }; |
||
610 | const int mate[64] = { |
||
611 | 200, 180, 160, 140, 140, 160, 180, 200, |
||
612 | 180, 160, 140, 120, 120, 140, 160, 180, |
||
613 | 160, 140, 120, 100, 100, 120, 140, 160, |
||
614 | 140, 120, 100, 100, 100, 100, 120, 140, |
||
615 | 140, 120, 100, 100, 100, 100, 120, 140, |
||
616 | 160, 140, 120, 100, 100, 120, 140, 160, |
||
617 | 180, 160, 140, 120, 120, 140, 160, 180, |
||
618 | 200, 180, 160, 140, 140, 160, 180, 200 |
||
619 | }; |
||
620 | int knight_outpost[2][64] = { |
||
621 | { 0, 0, 0, 0, 0, 0, 0, 0, |
||
622 | 0, 0, 0, 0, 0, 0, 0, 0, |
||
623 | 0, 1, 4, 4, 4, 4, 1, 0, |
||
624 | 0, 2, 6, 8, 8, 6, 2, 0, |
||
625 | 0, 1, 4, 4, 4, 4, 1, 0, /* [black][64] */ |
||
626 | 0, 0, 0, 0, 0, 0, 0, 0, |
||
627 | 0, 0, 0, 0, 0, 0, 0, 0, |
||
628 | 0, 0, 0, 0, 0, 0, 0, 0 }, |
||
629 | |||
630 | { 0, 0, 0, 0, 0, 0, 0, 0, |
||
631 | 0, 0, 0, 0, 0, 0, 0, 0, |
||
632 | 0, 0, 0, 0, 0, 0, 0, 0, |
||
633 | 0, 1, 4, 4, 4, 4, 1, 0, |
||
634 | 0, 2, 6, 8, 8, 6, 2, 0, /* [white][64] */ |
||
635 | 0, 1, 4, 4, 4, 4, 1, 0, |
||
636 | 0, 0, 0, 0, 0, 0, 0, 0, |
||
637 | 0, 0, 0, 0, 0, 0, 0, 0 } |
||
638 | }; |
||
639 | int bishop_outpost[2][64] = { |
||
640 | { 0, 0, 0, 0, 0, 0, 0, 0, |
||
641 | -1, 0, 0, 0, 0, 0, 0,-1, |
||
642 | 0, 0, 1, 1, 1, 1, 0, 0, |
||
643 | 0, 1, 3, 3, 3, 3, 1, 0, |
||
644 | 0, 3, 5, 5, 5, 5, 3, 0, /* [black][64] */ |
||
645 | 0, 1, 2, 2, 2, 2, 1, 0, |
||
646 | 0, 0, 0, 0, 0, 0, 0, 0, |
||
647 | 0, 0, 0, 0, 0, 0, 0, 0 }, |
||
648 | |||
649 | { 0, 0, 0, 0, 0, 0, 0, 0, |
||
650 | 0, 0, 0, 0, 0, 0, 0, 0, |
||
651 | 0, 1, 2, 2, 2, 2, 1, 0, |
||
652 | 0, 3, 5, 5, 5, 5, 3, 0, |
||
653 | 0, 1, 3, 3, 3, 3, 1, 0, /* [white][64] */ |
||
654 | 0, 0, 1, 1, 1, 1, 0, 0, |
||
655 | -1, 0, 0, 0, 0, 0, 0,-1, |
||
656 | 0, 0, 0, 0, 0, 0, 0, 0 } |
||
657 | }; |
||
658 | int pval[2][2][64] = { |
||
659 | {{ 0, 0, 0, 0, 0, 0, 0, 0, |
||
660 | 56, 66, 66, 66, 66, 66, 66, 56, |
||
661 | 0, 10, 10, 30, 30, 10, 10, 0, |
||
662 | -4, 6, 6, 16, 16, 6, 6, -4, |
||
663 | -7, 3, 3, 13, 13, 3, 3, -7, /* [mg][black][64] */ |
||
664 | -9, 1, 1, 10, 10, 1, 1, -9, |
||
665 | -10, 0, 0, -12, -12, 0, 0, -10, |
||
666 | 0, 0, 0, 0, 0, 0, 0, 0 }, |
||
667 | |||
668 | { 0, 0, 0, 0, 0, 0, 0, 0, |
||
669 | -10, 0, 0, -12, -12, 0, 0, -10, |
||
670 | -9, 1, 1, 10, 10, 1, 1, -9, |
||
671 | -7, 3, 3, 13, 13, 3, 3, -7, |
||
672 | -4, 6, 6, 16, 16, 6, 6, -4, /* [mg][white][64] */ |
||
673 | 0, 10, 10, 30, 30, 10, 10, 0, |
||
674 | 56, 66, 66, 66, 66, 66, 66, 56, |
||
675 | 0, 0, 0, 0, 0, 0, 0, 0 }}, |
||
676 | |||
677 | {{ 0, 0, 0, 0, 0, 0, 0, 0, |
||
678 | 56, 66, 66, 66, 66, 66, 66, 56, |
||
679 | 0, 10, 10, 30, 30, 10, 10, 0, |
||
680 | -4, 6, 6, 16, 16, 6, 6, -4, |
||
681 | -7, 3, 3, 13, 13, 3, 3, -7, /* [eg][black][64] */ |
||
682 | -9, 1, 1, 10, 10, 1, 1, -9, |
||
683 | -10, 0, 0, -12, -12, 0, 0, -10, |
||
684 | 0, 0, 0, 0, 0, 0, 0, 0 }, |
||
685 | |||
686 | { 0, 0, 0, 0, 0, 0, 0, 0, |
||
687 | -10, 0, 0, -12, -12, 0, 0, -10, |
||
688 | -9, 1, 1, 10, 10, 1, 1, -9, |
||
689 | -7, 3, 3, 13, 13, 3, 3, -7, |
||
690 | -4, 6, 6, 16, 16, 6, 6, -4, /* [eg][white][64] */ |
||
691 | 0, 10, 10, 30, 30, 10, 10, 0, |
||
692 | 56, 66, 66, 66, 66, 66, 66, 56, |
||
693 | 0, 0, 0, 0, 0, 0, 0, 0 }} |
||
694 | }; |
||
695 | int nval[2][2][64] = { |
||
696 | {{-29, -19, -19, -9, -9, -19, -19, -29, |
||
697 | 1, 12, 18, 22, 22, 18, 12, 1, |
||
698 | 1, 14, 23, 27, 27, 23, 14, 1, |
||
699 | 1, 14, 23, 28, 28, 23, 14, 1, |
||
700 | 1, 12, 21, 24, 24, 21, 12, 1, /* [mg][black][64] */ |
||
701 | 1, 2, 19, 17, 17, 19, 2, 1, |
||
702 | 1, 2, 2, 2, 2, 2, 2, 1, |
||
703 | -19, -19, -19, -19, -19, -19, -19, -19 }, |
||
704 | |||
705 | {-19, -19, -19, -19, -19, -19, -19, -19, |
||
706 | 1, 2, 2, 2, 2, 2, 2, 1, |
||
707 | 1, 2, 19, 17, 17, 19, 2, 1, |
||
708 | 1, 12, 21, 24, 24, 21, 12, 1, |
||
709 | 1, 14, 23, 28, 28, 23, 14, 1, /* [mg][white][64] */ |
||
710 | 1, 14, 23, 27, 27, 23, 14, 1, |
||
711 | 1, 12, 18, 22, 22, 18, 12, 1, |
||
712 | -29, -19, -19, -9, -9, -19, -19, -29 }}, |
||
713 | |||
714 | {{-29, -19, -19, -9, -9, -19, -19, -29, |
||
715 | 1, 12, 18, 22, 22, 18, 12, 1, |
||
716 | 1, 14, 23, 27, 27, 23, 14, 1, |
||
717 | 1, 14, 23, 28, 28, 23, 14, 1, |
||
718 | 1, 12, 21, 24, 24, 21, 12, 1, /* [eg][black][64] */ |
||
719 | 1, 2, 19, 17, 17, 19, 2, 1, |
||
720 | 1, 2, 2, 2, 2, 2, 2, 1, |
||
721 | -19, -19, -19, -19, -19, -19, -19, -19 }, |
||
722 | |||
723 | {-19, -19, -19, -19, -19, -19, -19, -19, |
||
724 | 1, 2, 2, 2, 2, 2, 2, 1, |
||
725 | 1, 2, 19, 17, 17, 19, 2, 1, |
||
726 | 1, 12, 21, 24, 24, 21, 12, 1, |
||
727 | 1, 14, 23, 28, 28, 23, 14, 1, /* [eg][white][64] */ |
||
728 | 1, 14, 23, 27, 27, 23, 14, 1, |
||
729 | 1, 12, 18, 22, 22, 18, 12, 1, |
||
730 | -29, -19, -19, -9, -9, -19, -19, -29 }} |
||
731 | }; |
||
732 | int bval[2][2][64] = { |
||
733 | {{ 0, 0, 0, 0, 0, 0, 0, 0, |
||
734 | 0, 4, 4, 4, 4, 4, 4, 0, |
||
735 | 0, 4, 8, 8, 8, 8, 4, 0, |
||
736 | 0, 4, 8, 12, 12, 8, 4, 0, |
||
737 | 0, 4, 8, 12, 12, 8, 4, 0, /* [mg][black][64] */ |
||
738 | 0, 4, 8, 8, 8, 8, 4, 0, |
||
739 | 0, 4, 4, 4, 4, 4, 4, 0, |
||
740 | -15, -15, -15, -15, -15, -15, -15, -15}, |
||
741 | |||
742 | {-15, -15, -15, -15, -15, -15, -15, -15, |
||
743 | 0, 4, 4, 4, 4, 4, 4, 0, |
||
744 | 0, 4, 8, 8, 8, 8, 4, 0, |
||
745 | 0, 4, 8, 12, 12, 8, 4, 0, |
||
746 | 0, 4, 8, 12, 12, 8, 4, 0, /* [mg][white][64] */ |
||
747 | 0, 4, 8, 8, 8, 8, 4, 0, |
||
748 | 0, 4, 4, 4, 4, 4, 4, 0, |
||
749 | 0, 0, 0, 0, 0, 0, 0, 0}}, |
||
750 | {{ 0, 0, 0, 0, 0, 0, 0, 0, |
||
751 | 0, 4, 4, 4, 4, 4, 4, 0, |
||
752 | 0, 4, 8, 8, 8, 8, 4, 0, |
||
753 | 0, 4, 8, 12, 12, 8, 4, 0, |
||
754 | 0, 4, 8, 12, 12, 8, 4, 0, /* [eg][black][64] */ |
||
755 | 0, 4, 8, 8, 8, 8, 4, 0, |
||
756 | 0, 4, 4, 4, 4, 4, 4, 0, |
||
757 | -15, -15, -15, -15, -15, -15, -15, -15}, |
||
758 | |||
759 | {-15, -15, -15, -15, -15, -15, -15, -15, |
||
760 | 0, 4, 4, 4, 4, 4, 4, 0, |
||
761 | 0, 4, 8, 8, 8, 8, 4, 0, |
||
762 | 0, 4, 8, 12, 12, 8, 4, 0, |
||
763 | 0, 4, 8, 12, 12, 8, 4, 0, /* [eg][white][64] */ |
||
764 | 0, 4, 8, 8, 8, 8, 4, 0, |
||
765 | 0, 4, 4, 4, 4, 4, 4, 0, |
||
766 | 0, 0, 0, 0, 0, 0, 0, 0}} |
||
767 | }; |
||
768 | int qval[2][2][64] = { |
||
769 | {{ 0, 0, 0, 0, 0, 0, 0, 0, |
||
770 | 0, 0, 4, 4, 4, 4, 0, 0, |
||
771 | 0, 4, 4, 6, 6, 4, 4, 0, |
||
772 | 0, 4, 6, 8, 8, 6, 4, 0, |
||
773 | 0, 4, 6, 8, 8, 6, 4, 0, /* [mg][black][64] */ |
||
774 | 0, 4, 4, 6, 6, 4, 4, 0, |
||
775 | 0, 0, 4, 4, 4, 4, 0, 0, |
||
776 | 0, 0, 0, 0, 0, 0, 0, 0 }, |
||
777 | |||
778 | { 0, 0, 0, 0, 0, 0, 0, 0, |
||
779 | 0, 0, 4, 4, 4, 4, 0, 0, |
||
780 | 0, 4, 4, 6, 6, 4, 4, 0, |
||
781 | 0, 4, 6, 8, 8, 6, 4, 0, |
||
782 | 0, 4, 6, 8, 8, 6, 4, 0, /* [mg][white][64] */ |
||
783 | 0, 4, 4, 6, 6, 4, 4, 0, |
||
784 | 0, 0, 4, 4, 4, 4, 0, 0, |
||
785 | 0, 0, 0, 0, 0, 0, 0, 0 }}, |
||
786 | |||
787 | {{ 0, 0, 0, 0, 0, 0, 0, 0, |
||
788 | 0, 0, 4, 4, 4, 4, 0, 0, |
||
789 | 0, 4, 4, 6, 6, 4, 4, 0, |
||
790 | 0, 4, 6, 8, 8, 6, 4, 0, |
||
791 | 0, 4, 6, 8, 8, 6, 4, 0, /* [eg][black][64] */ |
||
792 | 0, 4, 4, 6, 6, 4, 4, 0, |
||
793 | 0, 0, 4, 4, 4, 4, 0, 0, |
||
794 | 0, 0, 0, 0, 0, 0, 0, 0 }, |
||
795 | |||
796 | { 0, 0, 0, 0, 0, 0, 0, 0, |
||
797 | 0, 0, 4, 4, 4, 4, 0, 0, |
||
798 | 0, 4, 4, 6, 6, 4, 4, 0, |
||
799 | 0, 4, 6, 8, 8, 6, 4, 0, |
||
800 | 0, 4, 6, 8, 8, 6, 4, 0, /* [eg][white][64] */ |
||
801 | 0, 4, 4, 6, 6, 4, 4, 0, |
||
802 | 0, 0, 4, 4, 4, 4, 0, 0, |
||
803 | 0, 0, 0, 0, 0, 0, 0, 0 }} |
||
804 | }; |
||
805 | int kval_n[2][64] = { |
||
806 | {-40, -40, -40, -40, -40, -40, -40, -40, |
||
807 | -40, -10, -10, -10, -10, -10, -10, -40, |
||
808 | -40, -10, 60, 60, 60, 60, -10, -40, |
||
809 | -40, -10, 60, 60, 60, 60, -10, -40, |
||
810 | -40, -10, 40, 40, 40, 40, -10, -40, /* [black][64] */ |
||
811 | -40, -10, 20, 20, 20, 20, -10, -40, |
||
812 | -40, -10, -10, -10, -10, -10, -10, -40, |
||
813 | -40, -40, -40, -40, -40, -40, -40, -40 }, |
||
814 | |||
815 | {-40, -40, -40, -40, -40, -40, -40, -40, |
||
816 | -40, -10, -10, -10, -10, -10, -10, -40, |
||
817 | -40, -10, 20, 20, 20, 20, -10, -40, |
||
818 | -40, -10, 40, 40, 40, 40, -10, -40, |
||
819 | -40, -10, 60, 60, 60, 60, -10, -40, /* [white][64] */ |
||
820 | -40, -10, 60, 60, 60, 60, -10, -40, |
||
821 | -40, -10, -10, -10, -10, -10, -10, -40, |
||
822 | -40, -40, -40, -40, -40, -40, -40, -40 } |
||
823 | }; |
||
824 | int kval_k[2][64] = { |
||
825 | {-60, -40, -20, -20, -20, -20, -20, -20, |
||
826 | -60, -40, -20, 20, 40, 40, 40, 40, |
||
827 | -60, -40, -20, 20, 60, 60, 60, 40, |
||
828 | -60, -40, -20, 20, 60, 60, 60, 40, |
||
829 | -60, -40, -20, 20, 40, 40, 40, 40, /* [black][64] */ |
||
830 | -60, -40, -20, 20, 20, 20, 20, 20, |
||
831 | -60, -40, -20, 0, 0, 0, 0, 0, |
||
832 | -60, -40, -20, -20, -20, -20, -20, -20 }, |
||
833 | |||
834 | {-60, -40, -20, -20, -20, -20, -20, -20, |
||
835 | -60, -40, -20, 0, 0, 0, 0, 0, |
||
836 | -60, -40, -20, 20, 20, 20, 20, 20, |
||
837 | -60, -40, -20, 20, 40, 40, 40, 40, |
||
838 | -60, -40, -20, 20, 60, 60, 60, 40, /* [white][64] */ |
||
839 | -60, -40, -20, 20, 60, 60, 60, 40, |
||
840 | -60, -40, -20, 20, 40, 40, 40, 40, |
||
841 | -60, -40, -20, -20, -20, -20, -20, -20 } |
||
842 | }; |
||
843 | int kval_q[2][64] = { |
||
844 | {-20, -20, -20, -20, -20, -20, -40, -60, |
||
845 | 40, 40, 40, 40, 20, -20, -40, -60, |
||
846 | 40, 60, 60, 60, 20, -20, -40, -60, |
||
847 | 40, 60, 60, 60, 20, -20, -40, -60, |
||
848 | 40, 40, 40, 40, 20, -20, -40, -60, /* [black][64] */ |
||
849 | 20, 20, 20, 20, 20, -20, -40, -60, |
||
850 | 0, 0, 0, 0, 0, -20, -40, -60, |
||
851 | -20, -20, -20, -20, -20, -20, -40, -60 }, |
||
852 | |||
853 | {-20, -20, -20, -20, -20, -20, -40, -60, |
||
854 | 0, 0, 0, 0, 0, -20, -40, -60, |
||
855 | 20, 20, 20, 20, 20, -20, -40, -60, |
||
856 | 40, 40, 40, 40, 20, -20, -40, -60, |
||
857 | 40, 60, 60, 60, 20, -20, -40, -60, /* [white][64] */ |
||
858 | 40, 60, 60, 60, 20, -20, -40, -60, |
||
859 | 40, 40, 40, 40, 20, -20, -40, -60, |
||
860 | -20, -20, -20, -20, -20, -20, -40, -60 } |
||
861 | }; |
||
862 | int safety_vector[16] = { |
||
863 | 0, 7, 14, 21, 28, 35, 42, 49, |
||
864 | 56, 63, 70, 77, 84, 91, 98, 105 |
||
865 | }; |
||
866 | int tropism_vector[16] = { |
||
867 | 0, 1, 2, 3, 4, 5, 11, 20, |
||
868 | 32, 47, 65, 86, 110, 137, 167, 200 |
||
869 | }; |
||
870 | const int p_values[13] = { 10000, 900, 500, 300, 300, 100, 0, |
||
871 | 100, 300, 300, 500, 900, 9900 |
||
872 | }; |
||
873 | const int pcval[7] = { 0, 100, 300, 300, 500, 900, 9900 }; |
||
874 | const int p_vals[7] = { 0, 1, 3, 3, 5, 9, 99 }; |
||
875 | const int pieces[2][7] = { |
||
876 | { 0, -1, -2, -3, -4, -5, -6 }, |
||
877 | { 0, +1, +2, +3, +4, +5, +6 } |
||
878 | }; |
||
879 | int piece_values[7][2] = { {0, 0}, |
||
880 | {-PAWN_VALUE, PAWN_VALUE}, {-KNIGHT_VALUE, KNIGHT_VALUE}, |
||
881 | {-BISHOP_VALUE, BISHOP_VALUE}, {-ROOK_VALUE, ROOK_VALUE}, |
||
882 | {-QUEEN_VALUE, QUEEN_VALUE}, {-KING_VALUE, KING_VALUE} |
||
883 | }; |
||
884 | int pawn_can_promote = 525; |
||
885 | int wtm_bonus[2] = { 5, 8 }; |
||
886 | int undeveloped_piece = 12; |
||
887 | int pawn_connected[2] = { 4, 8 }; |
||
888 | int pawn_isolated[2] = { 18, 21 }; |
||
889 | int pawn_weak[2] = { 8, 18 }; |
||
890 | int lower_n = 16; |
||
891 | int mobility_score_n[4] = { 1, 2, 3, 4 }; |
||
892 | int lower_b = 10; |
||
893 | int bishop_trapped = 174; |
||
894 | int bishop_with_wing_pawns[2] = { 18, 36 }; |
||
895 | int bishop_pair[2] = { 38, 56 }; |
||
896 | int mobility_score_b[4] = { 1, 2, 3, 4 }; |
||
897 | int mobility_score_r[4] = { 1, 2, 3, 4 }; |
||
898 | int rook_on_7th[2] = { 25, 35 }; |
||
899 | int rook_open_file[2] = { 35, 20 }; |
||
900 | int rook_half_open_file[2] = { 10, 10 }; |
||
901 | int rook_trapped = 60; |
||
902 | int open_file[8] = { 6, 5, 4, 4, 4, 4, 5, 6 }; |
||
903 | int half_open_file[8] = { 4, 4, 3, 3, 3, 3, 4, 4 }; |
||
904 | int king_safety_mate_threat = 600; |
||
905 | int king_king_tropism = 10; |
||
906 | int development_thematic = 12; |
||
907 | int development_losing_castle = 20; |
||
908 | int development_not_castled = 20; |
||
909 | /* |
||
910 | First term is a character string explaining what the eval |
||
911 | term is used for. |
||
912 | |||
913 | Second term is the "type" of the value. |
||
914 | 0 = heading entry (no values, just a category name to display). |
||
915 | 1 = scalar value. |
||
916 | 2 = array[mg] |
||
917 | 3 = array[mg][side][64]. These values are displayed as 8x8 |
||
918 | boards with white values at the bottom, and the ranks/files |
||
919 | labeled to make them easier to read. |
||
920 | 4 = array[side][64] |
||
921 | 5 = array[rank] |
||
922 | 6 = array[mg][8] |
||
923 | |||
924 | Third term is the "size" of the scoring term, where 0 is a |
||
925 | scalar value, otherwise it is the actual number of elements in |
||
926 | an array of values. |
||
927 | |||
928 | Fourth term is a pointer to the data value(s). |
||
929 | */ |
||
930 | |||
931 | {"search options ", 0, 0, NULL}, /* 0 */ |
||
932 | {"check extension ", 1, 0, &check_depth}, |
||
933 | {"null-move reduction ", 1, 0, &null_depth}, |
||
934 | {"LMR min distance to frontier ", 1, 0, &LMR_remaining_depth}, |
||
935 | {"LMR min reduction ", 1, 0, &LMR_min_reduction}, |
||
936 | {"LMR max reduction ", 1, 0, &LMR_max_reduction}, |
||
937 | {"prune depth ", 1, 0, &pruning_depth}, |
||
938 | {"prune margin [remain_depth] ", 5, 8, pruning_margin}, |
||
939 | {NULL, 0, 0, NULL}, |
||
940 | {NULL, 0, 0, NULL}, |
||
941 | {"raw piece values ", 0, 0, NULL}, /* 10 */ |
||
942 | {"pawn value ", 2, 2, piece_values[pawn]}, |
||
943 | {"knight value ", 2, 2, piece_values[knight]}, |
||
944 | {"bishop value ", 2, 2, piece_values[bishop]}, |
||
945 | {"rook value ", 2, 2, piece_values[rook]}, |
||
946 | {"queen value ", 2, 2, piece_values[queen]}, |
||
947 | {NULL, 0, 0, NULL}, |
||
948 | {NULL, 0, 0, NULL}, |
||
949 | {NULL, 0, 0, NULL}, |
||
950 | {NULL, 0, 0, NULL}, |
||
951 | {"miscellaneous scoring values ", 0, 0, NULL}, /* 20 */ |
||
952 | {"wtm bonus ", 2, 2, wtm_bonus}, |
||
953 | {"draw score ", 1, 0, &abs_draw_score}, |
||
954 | #if defined(SKILL) |
||
955 | {"skill level setting ", 1, 0, &skill}, |
||
956 | #else |
||
957 | {NULL, 0, 0, NULL}, |
||
958 | #endif |
||
959 | {NULL, 0, 0, NULL}, |
||
960 | |||
961 | {NULL, 0, 0, NULL}, |
||
962 | {NULL, 0, 0, NULL}, |
||
963 | {NULL, 0, 0, NULL}, |
||
964 | {NULL, 0, 0, NULL}, |
||
965 | {"pawn evaluation ", 0, 0, NULL}, /* 30 */ |
||
966 | {"pawn piece/square table (white) ", 3, 256, (int *) pval}, |
||
967 | {"pawn connected ", 2, 2, pawn_connected}, |
||
968 | {"pawn isolated ", 2, 2, pawn_isolated}, |
||
969 | {"pawn weak ", 2, 2, pawn_weak}, |
||
970 | {"outside passed pawn ", 2, 2, outside_passed}, |
||
971 | {"hidden passed pawn ", 2, 2, passed_pawn_hidden}, |
||
972 | {"doubled pawn ", 2, 2, doubled_pawn_value}, |
||
973 | {"candidate passed pawn [rank] ", 6, 16, (int *) passed_pawn_candidate}, |
||
974 | {"passed pawn [rank] ", 6, 16, (int *) passed_pawn_value}, |
||
975 | {"passed pawn blocked by enemy [rank] ", 6, 16, (int *) passed_pawn_blockaded_by_enemy}, |
||
976 | {"passed pawn blocked by friend [rank] ", 6, 16, (int *) passed_pawn_blockaded_by_friendly}, |
||
977 | {"passed pawn connected [rank] ", 6, 16, (int *) passed_pawn_connected}, |
||
978 | {"passed pawn obstructed [rank] ", 5, 8, (int *) passed_pawn_obstructed}, |
||
979 | {"passed pawn far away [rank] ", 5, 8, (int *) passed_pawn_far_away}, |
||
980 | {"passed pawn not far away [rank] ", 5, 8, (int *) passed_pawn_not_far_away}, |
||
981 | {"pawn can promote ", 1, 0, &pawn_can_promote}, |
||
982 | {NULL, 0, 0, NULL}, |
||
983 | {NULL, 0, 0, NULL}, |
||
984 | {NULL, 0, 0, NULL}, |
||
985 | {"knight scoring ", 0, 0, NULL}, /* 50 */ |
||
986 | {"knight piece/square table (white) ", 3, 256, (int *) nval}, |
||
987 | {"knight outpost [square] ", 4, 128, (int *) knight_outpost}, |
||
988 | {"knight king tropism [distance] ", 5, 8, king_tropism_n}, |
||
989 | {"knight mobility ", 5, 4, mobility_score_n}, |
||
990 | {NULL, 0, 0, NULL}, |
||
991 | {NULL, 0, 0, NULL}, |
||
992 | {NULL, 0, 0, NULL}, |
||
993 | {NULL, 0, 0, NULL}, |
||
994 | {NULL, 0, 0, NULL}, |
||
995 | {"bishop scoring ", 0, 0, NULL}, /* 60 */ |
||
996 | {"bishop piece/square table (white) ", 3, 256, (int *) bval}, |
||
997 | {"bishop king tropism [distance] ", 5, 8, king_tropism_b}, |
||
998 | {"bishop mobility/square table ", 5, 4, mobility_score_b}, |
||
999 | {"bishop outpost [square] ", 4, 128, (int *) bishop_outpost}, |
||
1000 | {"bishop with wing pawns ", 2, 2, bishop_with_wing_pawns}, |
||
1001 | {"bishop pair ", 2, 2, bishop_pair}, |
||
1002 | {"bishop trapped ", 1, 0, &bishop_trapped}, |
||
1003 | {NULL, 0, 0, NULL}, |
||
1004 | {NULL, 0, 0, NULL}, |
||
1005 | {"rook scoring ", 0, 0, NULL}, /* 70 */ |
||
1006 | {"rook half open file ", 2, 2, rook_half_open_file}, |
||
1007 | {"rook open file ", 2, 2, rook_open_file}, |
||
1008 | {"rook king tropism [distance] ", 5, 8, king_tropism_r}, |
||
1009 | {"rook mobility/square table ", 5, 4, mobility_score_r}, |
||
1010 | {"rook on 7th ", 2, 2, rook_on_7th}, |
||
1011 | {"rook behind passed pawn ", 6, 16, &rook_behind_passed_pawn[0][0]}, |
||
1012 | {"rook trapped ", 1, 0, &rook_trapped}, |
||
1013 | {NULL, 0, 0, NULL}, |
||
1014 | {NULL, 0, 0, NULL}, |
||
1015 | {"queen scoring ", 0, 0, NULL}, /* 80 */ |
||
1016 | {"queen piece/square table (white) ", 3, 256, (int *) qval}, |
||
1017 | {"queen king tropism [distance] ", 5, 8, king_tropism_q}, |
||
1018 | {NULL, 0, 0, NULL}, |
||
1019 | {NULL, 0, 0, NULL}, |
||
1020 | {NULL, 0, 0, NULL}, |
||
1021 | {NULL, 0, 0, NULL}, |
||
1022 | {NULL, 0, 0, NULL}, |
||
1023 | {NULL, 0, 0, NULL}, |
||
1024 | {NULL, 0, 0, NULL}, |
||
1025 | {"king scoring ", 0, 0, NULL}, /* 90 */ |
||
1026 | {"king piece/square normal ", 4, 128, (int *)kval_n}, |
||
1027 | {"king piece/square kside pawns ", 4, 128, (int *)kval_k}, |
||
1028 | {"king piece/square qside pawns ", 4, 128, (int *)kval_q}, |
||
1029 | {"king safety pawn-shield vector ", 6, 16, safety_vector}, |
||
1030 | {"king safety tropism vector ", 6, 16, tropism_vector}, |
||
1031 | {"king safe open file [file] ", 5, 8, open_file}, |
||
1032 | {"king safe half-open file [file] ", 5, 8, half_open_file}, |
||
1033 | {"king king tropism (endgame) ", 1, 0, &king_king_tropism}, |
||
1034 | {NULL, 0, 0, NULL}, |
||
1035 | {"development scoring ", 0, 0, NULL}, /* 100 */ |
||
1036 | {"development thematic ", 1, 0, &development_thematic}, |
||
1037 | {"development losing castle rights ", 1, 0, &development_losing_castle}, |
||
1038 | {"development not castled ", 1, 0, &development_not_castled}, |
||
1039 | }; |
||
1040 | /* *INDENT-ON* */ |
||
1041 | |||
1042 |