Rev 154 | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 33 | pmbaty | 1 | #include "chess.h" |
| 2 | /* *INDENT-OFF* */#if !defined(INLINEASM) |
||
| 154 | pmbaty | 3 | unsigned char msb[65536]; |
| 33 | pmbaty | 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 | uint64_t mask_pawn_connected[2][64]; |
||
| 10 | uint64_t mask_pawn_isolated[64]; |
||
| 11 | uint64_t mask_passed[2][64]; |
||
| 12 | uint64_t mask_pattacks[2][64]; |
||
| 13 | uint64_t pawn_race[2][2][64]; |
||
| 14 | BOOK_POSITION book_buffer[BOOK_CLUSTER_SIZE]; |
||
| 15 | BOOK_POSITION book_buffer_char[BOOK_CLUSTER_SIZE]; |
||
| 16 | const int OOsqs[2][3] = {{E8, F8, G8}, {E1, F1, G1}}; |
||
| 17 | const int OOOsqs[2][3] = {{E8, D8, C8}, {E1, D1, C1}}; |
||
| 18 | const int OOfrom[2] = {E8, E1}; |
||
| 19 | const int OOto[2] = {G8, G1}; |
||
| 20 | const int OOOto[2] = {C8, C1}; |
||
| 21 | #define VERSION "25.2" |
||
| 22 | char version[8] = {VERSION}; |
||
| 23 | PLAYING_MODE mode = normal_mode; |
||
| 24 | int batch_mode = 0; /* no asynch reads */ |
||
| 25 | int swindle_mode = 1; /* try to swindle */ |
||
| 26 | int call_flag = 0; |
||
| 27 | int crafty_rating = 2500; |
||
| 28 | int opponent_rating = 2500; |
||
| 29 | int last_search_value = 0; |
||
| 30 | int FP_margin[16] = { 0, 100, 150, 200, 250, 300, 400, 500, |
||
| 108 | pmbaty | 31 | 600, 700, 800, 900, 1000, 1100, 1200, 1300 }; |
| 33 | pmbaty | 32 | int FP_depth = 7; |
| 33 | int LMP[16]; |
||
| 34 | int LMP_depth = 16; |
||
| 35 | int LMP_base = 3; |
||
| 36 | double LMP_scale = 1.9; |
||
| 37 | int pgn_suggested_percent = 0; |
||
| 38 | char pgn_event[128] = {"?"}; |
||
| 39 | char pgn_site[128] = {"?"}; |
||
| 40 | char pgn_date[128] = {"????.??.??"}; |
||
| 41 | char pgn_round[128] = {"?"}; |
||
| 42 | char pgn_white[128] = {"unknown"}; |
||
| 108 | pmbaty | 43 | char pgn_white_elo[128] = {""}; |
| 33 | pmbaty | 44 | char pgn_black[128] = {"Crafty " VERSION}; |
| 45 | char pgn_black_elo[128] = {""}; |
||
| 46 | char pgn_result[128] = {"*"}; |
||
| 47 | char *B_list[128]; |
||
| 48 | char *AK_list[128]; |
||
| 49 | char *GM_list[128]; |
||
| 50 | char *IM_list[128]; |
||
| 108 | pmbaty | 51 | char *SP_list[128]; |
| 52 | char *SP_opening_filename[128]; |
||
| 33 | pmbaty | 53 | char *SP_personality_filename[128]; |
| 108 | pmbaty | 54 | int output_format = 0; |
| 55 | #if defined(SYZYGY) |
||
| 56 | int EGTBlimit = 0; |
||
| 57 | int EGTB_use = 0; |
||
| 58 | int EGTB_draw = 0; |
||
| 59 | int EGTB_depth = 0; |
||
| 60 | size_t EGTB_cache_size = 4096 * 4096; |
||
| 61 | void *EGTB_cache = (void *) 0; |
||
| 62 | int EGTB_setup = 0; |
||
| 63 | #endif |
||
| 64 | int xboard = 0; |
||
| 65 | int xboard_done = 0; |
||
| 66 | int pong = 0; |
||
| 67 | int early_exit = 99; |
||
| 68 | char book_path[128] = {BOOKDIR}; |
||
| 69 | char log_path[128] = {LOGDIR}; |
||
| 70 | char tb_path[128] = {TBDIR}; |
||
| 71 | char rc_path[128] = {RCDIR}; |
||
| 72 | int initialized = 0; |
||
| 73 | int kibitz = 0; |
||
| 74 | int post = 0; |
||
| 75 | int log_id = 1; |
||
| 76 | int game_wtm = 1; |
||
| 77 | int last_opponent_move = 0; |
||
| 78 | int check_depth = 1; /* extend checks one ply */ |
||
| 79 | int null_depth = 3; /* R=3 + (next line) */ |
||
| 80 | int null_divisor = 6; /* R = null_depth + depth / 6 */ |
||
| 81 | int LMR_rdepth = 1; /* leave 1 full ply after reductions */ |
||
| 82 | int LMR_min= 1; /* minimum reduction 1 ply */ |
||
| 83 | int LMR_max= 15; /* maximum reduction 15 plies */ |
||
| 84 | double LMR_db = 1.8; /* depth is 1.8x as important as */ |
||
| 85 | double LMR_mb = 1.0; /* moves searched in the formula. */ |
||
| 86 | double LMR_s = 2.0; /* smaller numbers increase reductions. */ |
||
| 87 | uint8_t LMR[32][64]; |
||
| 88 | int rep_index; |
||
| 89 | int search_depth = 0; |
||
| 90 | uint64_t search_nodes = 0; |
||
| 91 | uint64_t temp_search_nodes = 0; |
||
| 92 | int search_move = 0; |
||
| 93 | int predicted = 0; |
||
| 94 | int time_used = 0; |
||
| 95 | int time_used_opponent = 0; |
||
| 96 | int analyze_mode = 0; |
||
| 97 | int annotate_mode = 0; |
||
| 98 | int input_status = 0; |
||
| 99 | int resign = 9; |
||
| 100 | int resign_counter = 0; |
||
| 101 | int resign_count = 5; |
||
| 102 | int draw_counter = 0; |
||
| 103 | int draw_count = 5; |
||
| 104 | int draw_offer_pending = 0; |
||
| 105 | int draw_offered = 0; |
||
| 106 | int offer_draws = 1; |
||
| 107 | int dynamic_draw_score = 1; |
||
| 108 | int adaptive_hash = 0; |
||
| 109 | size_t adaptive_hash_min = 0; |
||
| 110 | size_t adaptive_hash_max = 0; |
||
| 111 | size_t adaptive_hashp_min = 0; |
||
| 112 | size_t adaptive_hashp_max = 0; |
||
| 113 | int time_limit = 100; |
||
| 114 | int force = 0; |
||
| 115 | char initial_position[80] = {""}; |
||
| 116 | char ponder_text[512] = {""}; |
||
| 117 | char book_hint[512] = {""}; |
||
| 118 | int over = 0; |
||
| 119 | int usage_level = 0; |
||
| 120 | char audible_alarm = 0x07; |
||
| 121 | char speech = 0; |
||
| 122 | int book_accept_mask = ~03; |
||
| 123 | int book_reject_mask = 3; |
||
| 124 | int book_random = 1; |
||
| 125 | float book_weight_learn = 1.0f; // Pierre-Marie Baty -- fixed constant truncation |
||
| 126 | float book_weight_freq = 1.0f; // Pierre-Marie Baty -- fixed constant truncation |
||
| 127 | float book_weight_eval = 0.1f; // Pierre-Marie Baty -- fixed constant truncation |
||
| 128 | int book_search_trigger = 20; |
||
| 129 | int learn = 1; |
||
| 130 | int learning = 100; |
||
| 131 | int learn_value = 0; |
||
| 132 | int abort_search; /* 1 = abort / print stats, 2 = abort no print stats */ |
||
| 133 | int iteration; |
||
| 134 | int root_wtm = 1; |
||
| 135 | int last_root_value; |
||
| 136 | ROOT_MOVE root_moves[256]; |
||
| 137 | int n_root_moves; |
||
| 138 | int difficulty; |
||
| 139 | int absolute_time_limit; |
||
| 140 | int search_time_limit; |
||
| 141 | int burp; |
||
| 142 | int quit = 0; |
||
| 143 | unsigned opponent_start_time, opponent_end_time; |
||
| 144 | unsigned program_start_time, program_end_time; |
||
| 145 | unsigned start_time, end_time; |
||
| 146 | TREE *block[MAX_BLOCKS + 1]; |
||
| 147 | THREAD thread[CPUS]; |
||
| 148 | #if (CPUS > 1) |
||
| 149 | lock_t lock_smp, lock_io; |
||
| 150 | #if defined(UNIX) |
||
| 151 | pthread_attr_t attributes; |
||
| 152 | #endif |
||
| 153 | #endif |
||
| 154 | unsigned int hardware_processors; |
||
| 155 | /*unsigned*/ int smp_max_threads = 0; // Pierre-Marie Baty -- fixed type |
||
| 156 | unsigned int smp_split_group = 8; /* max threads per group */ |
||
| 157 | unsigned int smp_split_at_root = 1; /* enable split at root */ |
||
| 158 | unsigned int smp_min_split_depth = 5; /* don't split within 5 plies of tips */ |
||
| 159 | unsigned int smp_gratuitous_depth = 10; /* gratuitous splits if depth > 10 */ |
||
| 160 | unsigned int smp_gratuitous_limit = 6; /* max gratuitous splits / thread */ |
||
| 161 | int smp_nice = 1; /* terminate idle threads */ |
||
| 162 | int smp_affinity = 0; /* anything >= 0 is enabled */ |
||
| 163 | int smp_affinity_increment = 1; /* if physical cores are zero - N-1 |
||
| 164 | use 1, if physical cores are even |
||
| 165 | numbers and hyperthreaded cores are |
||
| 166 | odd use 2. For IBM POWER 8 use 8 */ |
||
| 167 | int smp_numa = 0; /* disables NUMA mode by default */ |
||
| 168 | /* enable if you really have NUMA */ |
||
| 169 | /* |
||
| 170 | This is the autotune configuration section. Each line represents one |
||
| 171 | smp search parameter that can be tuned. The first three values are the |
||
| 172 | min, max and increment that autotune will use for this paramenter. The |
||
| 173 | fourth parameter is a string autotune will display to explain what it is |
||
| 174 | currently tuning. The fifth parameter is the command used to change this |
||
| 175 | parameter (this is added to the .craftyrc/crafty.rc file after tuning is |
||
| 176 | completed. The last parameter is a pointer to the variable that must be |
||
| 177 | changed to adjust the parameter while running the autotune tests. |
||
| 178 | */ |
||
| 179 | int autotune_params = 4; |
||
| 180 | struct autotune tune[16] = { |
||
| 181 | { 4, 20, 4, "max thread group", "smpgroup", &smp_split_group}, |
||
| 182 | { 4, 8, 1, "min split depth", "smpmin", &smp_min_split_depth}, |
||
| 183 | {10, 16, 2, "min gratuitous split depth", "smpgsd", &smp_gratuitous_depth}, |
||
| 184 | { 1, 8, 2, "gratuitous split limit", "smpgsl", &smp_gratuitous_limit}, |
||
| 185 | }; |
||
| 186 | unsigned parallel_splits; |
||
| 187 | unsigned parallel_splits_wasted; |
||
| 188 | unsigned parallel_aborts; |
||
| 189 | unsigned parallel_joins; |
||
| 190 | unsigned busy_percent = 0; |
||
| 191 | uint64_t game_max_blocks = 0; |
||
| 192 | volatile int smp_split = 0; |
||
| 193 | volatile int smp_threads = 0; |
||
| 194 | volatile int initialized_threads = 0; |
||
| 195 | int crafty_is_white = 0; |
||
| 196 | unsigned nodes_between_time_checks = 1000000; |
||
| 197 | unsigned nodes_per_second = 1000000; |
||
| 198 | int next_time_check = 100000; |
||
| 199 | int transposition_age = 0; |
||
| 200 | int thinking = 0; |
||
| 201 | int pondering = 0; |
||
| 202 | int puzzling = 0; |
||
| 203 | int booking = 0; |
||
| 204 | /************************************************************ |
||
| 205 | * * |
||
| 206 | * 1 -> display move/time/results/etc. * |
||
| 207 | * 2 -> display PV. * |
||
| 208 | * 4 -> display fail high / fail low moves * |
||
| 209 | * 8 -> display search statistics. * |
||
| 210 | * 16 -> display root moves as they are searched. * |
||
| 211 | * 32 -> display general informational messages. * |
||
| 212 | * 64 -> display ply-1 move list / flags after each * |
||
| 213 | * iteration. * |
||
| 214 | * 128 -> display root moves and scores before search * |
||
| 215 | * begins. * |
||
| 216 | * 2048 -> error messages (can not be disabled). * |
||
| 217 | * * |
||
| 218 | ************************************************************ |
||
| 219 | */ |
||
| 220 | int display_options = 1 | 2 | 8 | 16 | 32 | 2048; |
||
| 221 | unsigned noise_level = 100; |
||
| 222 | int noise_block = 0; |
||
| 223 | int tc_moves = 60; |
||
| 224 | int tc_time = 180000; |
||
| 225 | int tc_time_remaining[2] = {180000, 180000}; |
||
| 226 | int tc_moves_remaining[2] = {60, 60}; |
||
| 227 | int tc_secondary_moves = 30; |
||
| 228 | int tc_secondary_time = 90000; |
||
| 229 | int tc_increment = 0; |
||
| 230 | int tc_sudden_death = 0; |
||
| 231 | int tc_safety_margin = 0; |
||
| 232 | int draw_score[2] = {0, 0}; |
||
| 233 | char kibitz_text[4096]; |
||
| 234 | int kibitz_depth; |
||
| 235 | int move_number = 1; |
||
| 236 | int moves_out_of_book = 0; |
||
| 237 | int first_nonbook_factor = 0; |
||
| 238 | int first_nonbook_span = 0; |
||
| 239 | #if defined(SKILL) |
||
| 240 | int skill = 100; |
||
| 241 | #endif |
||
| 242 | int show_book = 0; |
||
| 243 | int book_selection_width = 5; |
||
| 244 | int ponder = 1; |
||
| 245 | int trace_level = 0; |
||
| 246 | /* for the following 6 lines, each pair should have */ |
||
| 247 | /* the same numeric value (the size value). */ |
||
| 248 | size_t hash_table_size = 1ull << 20; |
||
| 249 | uint64_t hash_mask = ((1ull << 20) - 1) & ~3; |
||
| 250 | size_t hash_path_size = 1ull << 16; |
||
| 251 | uint64_t hash_path_mask = ((1ull << 16) - 1) & ~15; |
||
| 252 | size_t pawn_hash_table_size = 1ull << 18; |
||
| 253 | uint64_t pawn_hash_mask = (1ull << 18) - 1; |
||
| 254 | uint64_t mask_clear_entry = 0xff9ffffffffe0000ull; |
||
| 255 | int abs_draw_score = 0; |
||
| 256 | int accept_draws = 1; |
||
| 257 | const char translate[13] = |
||
| 258 | {'k', 'q', 'r', 'b', 'n', 'p', 0, 'P', 'N', 'B', 'R', 'Q', 'K'}; |
||
| 259 | const uint64_t magic_bishop[64] = { |
||
| 260 | 0x0002020202020200ull, 0x0002020202020000ull, 0x0004010202000000ull, |
||
| 261 | 0x0004040080000000ull, 0x0001104000000000ull, 0x0000821040000000ull, |
||
| 262 | 0x0000410410400000ull, 0x0000104104104000ull, 0x0000040404040400ull, |
||
| 263 | 0x0000020202020200ull, 0x0000040102020000ull, 0x0000040400800000ull, |
||
| 264 | 0x0000011040000000ull, 0x0000008210400000ull, 0x0000004104104000ull, |
||
| 265 | 0x0000002082082000ull, 0x0004000808080800ull, 0x0002000404040400ull, |
||
| 266 | 0x0001000202020200ull, 0x0000800802004000ull, 0x0000800400A00000ull, |
||
| 267 | 0x0000200100884000ull, 0x0000400082082000ull, 0x0000200041041000ull, |
||
| 268 | 0x0002080010101000ull, 0x0001040008080800ull, 0x0000208004010400ull, |
||
| 269 | 0x0000404004010200ull, 0x0000840000802000ull, 0x0000404002011000ull, |
||
| 270 | 0x0000808001041000ull, 0x0000404000820800ull, 0x0001041000202000ull, |
||
| 271 | 0x0000820800101000ull, 0x0000104400080800ull, 0x0000020080080080ull, |
||
| 272 | 0x0000404040040100ull, 0x0000808100020100ull, 0x0001010100020800ull, |
||
| 273 | 0x0000808080010400ull, 0x0000820820004000ull, 0x0000410410002000ull, |
||
| 274 | 0x0000082088001000ull, 0x0000002011000800ull, 0x0000080100400400ull, |
||
| 275 | 0x0001010101000200ull, 0x0002020202000400ull, 0x0001010101000200ull, |
||
| 276 | 0x0000410410400000ull, 0x0000208208200000ull, 0x0000002084100000ull, |
||
| 277 | 0x0000000020880000ull, 0x0000001002020000ull, 0x0000040408020000ull, |
||
| 278 | 0x0004040404040000ull, 0x0002020202020000ull, 0x0000104104104000ull, |
||
| 279 | 0x0000002082082000ull, 0x0000000020841000ull, 0x0000000000208800ull, |
||
| 280 | 0x0000000010020200ull, 0x0000000404080200ull, 0x0000040404040400ull, |
||
| 281 | 0x0002020202020200ull |
||
| 282 | }; |
||
| 283 | const uint64_t magic_bishop_mask[64] = { |
||
| 284 | 0x0040201008040200ull, 0x0000402010080400ull, 0x0000004020100A00ull, |
||
| 285 | 0x0000000040221400ull, 0x0000000002442800ull, 0x0000000204085000ull, |
||
| 286 | 0x0000020408102000ull, 0x0002040810204000ull, 0x0020100804020000ull, |
||
| 287 | 0x0040201008040000ull, 0x00004020100A0000ull, 0x0000004022140000ull, |
||
| 288 | 0x0000000244280000ull, 0x0000020408500000ull, 0x0002040810200000ull, |
||
| 289 | 0x0004081020400000ull, 0x0010080402000200ull, 0x0020100804000400ull, |
||
| 290 | 0x004020100A000A00ull, 0x0000402214001400ull, 0x0000024428002800ull, |
||
| 291 | 0x0002040850005000ull, 0x0004081020002000ull, 0x0008102040004000ull, |
||
| 292 | 0x0008040200020400ull, 0x0010080400040800ull, 0x0020100A000A1000ull, |
||
| 293 | 0x0040221400142200ull, 0x0002442800284400ull, 0x0004085000500800ull, |
||
| 294 | 0x0008102000201000ull, 0x0010204000402000ull, 0x0004020002040800ull, |
||
| 295 | 0x0008040004081000ull, 0x00100A000A102000ull, 0x0022140014224000ull, |
||
| 296 | 0x0044280028440200ull, 0x0008500050080400ull, 0x0010200020100800ull, |
||
| 297 | 0x0020400040201000ull, 0x0002000204081000ull, 0x0004000408102000ull, |
||
| 298 | 0x000A000A10204000ull, 0x0014001422400000ull, 0x0028002844020000ull, |
||
| 299 | 0x0050005008040200ull, 0x0020002010080400ull, 0x0040004020100800ull, |
||
| 300 | 0x0000020408102000ull, 0x0000040810204000ull, 0x00000A1020400000ull, |
||
| 301 | 0x0000142240000000ull, 0x0000284402000000ull, 0x0000500804020000ull, |
||
| 302 | 0x0000201008040200ull, 0x0000402010080400ull, 0x0002040810204000ull, |
||
| 303 | 0x0004081020400000ull, 0x000A102040000000ull, 0x0014224000000000ull, |
||
| 304 | 0x0028440200000000ull, 0x0050080402000000ull, 0x0020100804020000ull, |
||
| 305 | 0x0040201008040200ull |
||
| 306 | }; |
||
| 307 | const unsigned magic_bishop_shift[64] = { |
||
| 308 | 58, 59, 59, 59, 59, 59, 59, 58, |
||
| 309 | 59, 59, 59, 59, 59, 59, 59, 59, |
||
| 310 | 59, 59, 57, 57, 57, 57, 59, 59, |
||
| 311 | 59, 59, 57, 55, 55, 57, 59, 59, |
||
| 312 | 59, 59, 57, 55, 55, 57, 59, 59, |
||
| 313 | 59, 59, 57, 57, 57, 57, 59, 59, |
||
| 314 | 59, 59, 59, 59, 59, 59, 59, 59, |
||
| 315 | 58, 59, 59, 59, 59, 59, 59, 58 |
||
| 316 | }; |
||
| 317 | uint64_t magic_bishop_table[5248]; |
||
| 318 | uint64_t *magic_bishop_indices[64] = { |
||
| 319 | magic_bishop_table + 4992, magic_bishop_table + 2624, |
||
| 320 | magic_bishop_table + 256, magic_bishop_table + 896, |
||
| 321 | magic_bishop_table + 1280, magic_bishop_table + 1664, |
||
| 322 | magic_bishop_table + 4800, magic_bishop_table + 5120, |
||
| 323 | magic_bishop_table + 2560, magic_bishop_table + 2656, |
||
| 324 | magic_bishop_table + 288, magic_bishop_table + 928, |
||
| 325 | magic_bishop_table + 1312, magic_bishop_table + 1696, |
||
| 326 | magic_bishop_table + 4832, magic_bishop_table + 4928, |
||
| 327 | magic_bishop_table + 0, magic_bishop_table + 128, |
||
| 328 | magic_bishop_table + 320, magic_bishop_table + 960, |
||
| 329 | magic_bishop_table + 1344, magic_bishop_table + 1728, |
||
| 330 | magic_bishop_table + 2304, magic_bishop_table + 2432, |
||
| 331 | magic_bishop_table + 32, magic_bishop_table + 160, |
||
| 332 | magic_bishop_table + 448, magic_bishop_table + 2752, |
||
| 333 | magic_bishop_table + 3776, magic_bishop_table + 1856, |
||
| 334 | magic_bishop_table + 2336, magic_bishop_table + 2464, |
||
| 335 | magic_bishop_table + 64, magic_bishop_table + 192, |
||
| 336 | magic_bishop_table + 576, magic_bishop_table + 3264, |
||
| 337 | magic_bishop_table + 4288, magic_bishop_table + 1984, |
||
| 338 | magic_bishop_table + 2368, magic_bishop_table + 2496, |
||
| 339 | magic_bishop_table + 96, magic_bishop_table + 224, |
||
| 340 | magic_bishop_table + 704, magic_bishop_table + 1088, |
||
| 341 | magic_bishop_table + 1472, magic_bishop_table + 2112, |
||
| 342 | magic_bishop_table + 2400, magic_bishop_table + 2528, |
||
| 343 | magic_bishop_table + 2592, magic_bishop_table + 2688, |
||
| 344 | magic_bishop_table + 832, magic_bishop_table + 1216, |
||
| 345 | magic_bishop_table + 1600, magic_bishop_table + 2240, |
||
| 346 | magic_bishop_table + 4864, magic_bishop_table + 4960, |
||
| 347 | magic_bishop_table + 5056, magic_bishop_table + 2720, |
||
| 348 | magic_bishop_table + 864, magic_bishop_table + 1248, |
||
| 349 | magic_bishop_table + 1632, magic_bishop_table + 2272, |
||
| 350 | magic_bishop_table + 4896, magic_bishop_table + 5184 |
||
| 351 | }; |
||
| 352 | int16_t magic_bishop_mobility_table[5248]; |
||
| 353 | int16_t *magic_bishop_mobility_indices[64] = { |
||
| 354 | magic_bishop_mobility_table + 4992, magic_bishop_mobility_table + 2624, |
||
| 355 | magic_bishop_mobility_table + 256, magic_bishop_mobility_table + 896, |
||
| 356 | magic_bishop_mobility_table + 1280, magic_bishop_mobility_table + 1664, |
||
| 357 | magic_bishop_mobility_table + 4800, magic_bishop_mobility_table + 5120, |
||
| 358 | magic_bishop_mobility_table + 2560, magic_bishop_mobility_table + 2656, |
||
| 359 | magic_bishop_mobility_table + 288, magic_bishop_mobility_table + 928, |
||
| 360 | magic_bishop_mobility_table + 1312, magic_bishop_mobility_table + 1696, |
||
| 361 | magic_bishop_mobility_table + 4832, magic_bishop_mobility_table + 4928, |
||
| 362 | magic_bishop_mobility_table + 0, magic_bishop_mobility_table + 128, |
||
| 33 | pmbaty | 363 | magic_bishop_mobility_table + 320, magic_bishop_mobility_table + 960, |
| 108 | pmbaty | 364 | magic_bishop_mobility_table + 1344, magic_bishop_mobility_table + 1728, |
| 365 | magic_bishop_mobility_table + 2304, magic_bishop_mobility_table + 2432, |
||
| 366 | magic_bishop_mobility_table + 32, magic_bishop_mobility_table + 160, |
||
| 33 | pmbaty | 367 | magic_bishop_mobility_table + 448, magic_bishop_mobility_table + 2752, |
| 108 | pmbaty | 368 | magic_bishop_mobility_table + 3776, magic_bishop_mobility_table + 1856, |
| 33 | pmbaty | 369 | magic_bishop_mobility_table + 2336, magic_bishop_mobility_table + 2464, |
| 370 | magic_bishop_mobility_table + 64, magic_bishop_mobility_table + 192, |
||
| 371 | magic_bishop_mobility_table + 576, magic_bishop_mobility_table + 3264, |
||
| 372 | magic_bishop_mobility_table + 4288, magic_bishop_mobility_table + 1984, |
||
| 373 | magic_bishop_mobility_table + 2368, magic_bishop_mobility_table + 2496, |
||
| 374 | magic_bishop_mobility_table + 96, magic_bishop_mobility_table + 224, |
||
| 375 | magic_bishop_mobility_table + 704, magic_bishop_mobility_table + 1088, |
||
| 376 | magic_bishop_mobility_table + 1472, magic_bishop_mobility_table + 2112, |
||
| 377 | magic_bishop_mobility_table + 2400, magic_bishop_mobility_table + 2528, |
||
| 378 | magic_bishop_mobility_table + 2592, magic_bishop_mobility_table + 2688, |
||
| 379 | magic_bishop_mobility_table + 832, magic_bishop_mobility_table + 1216, |
||
| 380 | magic_bishop_mobility_table + 1600, magic_bishop_mobility_table + 2240, |
||
| 381 | magic_bishop_mobility_table + 4864, magic_bishop_mobility_table + 4960, |
||
| 382 | magic_bishop_mobility_table + 5056, magic_bishop_mobility_table + 2720, |
||
| 383 | magic_bishop_mobility_table + 864, magic_bishop_mobility_table + 1248, |
||
| 384 | magic_bishop_mobility_table + 1632, magic_bishop_mobility_table + 2272, |
||
| 385 | magic_bishop_mobility_table + 4896, magic_bishop_mobility_table + 5184 |
||
| 386 | }; |
||
| 387 | uint64_t magic_rook_table[102400]; |
||
| 388 | uint64_t *magic_rook_indices[64] = { |
||
| 389 | magic_rook_table + 86016, magic_rook_table + 73728, |
||
| 390 | magic_rook_table + 36864, magic_rook_table + 43008, |
||
| 391 | magic_rook_table + 47104, magic_rook_table + 51200, |
||
| 392 | magic_rook_table + 77824, magic_rook_table + 94208, |
||
| 393 | magic_rook_table + 69632, magic_rook_table + 32768, |
||
| 394 | magic_rook_table + 38912, magic_rook_table + 10240, |
||
| 395 | magic_rook_table + 14336, magic_rook_table + 53248, |
||
| 396 | magic_rook_table + 57344, magic_rook_table + 81920, |
||
| 397 | magic_rook_table + 24576, magic_rook_table + 33792, |
||
| 398 | magic_rook_table + 6144, magic_rook_table + 11264, |
||
| 399 | magic_rook_table + 15360, magic_rook_table + 18432, |
||
| 400 | magic_rook_table + 58368, magic_rook_table + 61440, |
||
| 401 | magic_rook_table + 26624, magic_rook_table + 4096, |
||
| 108 | pmbaty | 402 | magic_rook_table + 7168, magic_rook_table + 0, |
| 403 | magic_rook_table + 2048, magic_rook_table + 19456, |
||
| 404 | magic_rook_table + 22528, magic_rook_table + 63488, |
||
| 405 | magic_rook_table + 28672, magic_rook_table + 5120, |
||
| 406 | magic_rook_table + 8192, magic_rook_table + 1024, |
||
| 407 | magic_rook_table + 3072, magic_rook_table + 20480, |
||
| 408 | magic_rook_table + 23552, magic_rook_table + 65536, |
||
| 409 | magic_rook_table + 30720, magic_rook_table + 34816, |
||
| 410 | magic_rook_table + 9216, magic_rook_table + 12288, |
||
| 411 | magic_rook_table + 16384, magic_rook_table + 21504, |
||
| 412 | magic_rook_table + 59392, magic_rook_table + 67584, |
||
| 413 | magic_rook_table + 71680, magic_rook_table + 35840, |
||
| 414 | magic_rook_table + 39936, magic_rook_table + 13312, |
||
| 415 | magic_rook_table + 17408, magic_rook_table + 54272, |
||
| 33 | pmbaty | 416 | magic_rook_table + 60416, magic_rook_table + 83968, |
| 417 | magic_rook_table + 90112, magic_rook_table + 75776, |
||
| 418 | magic_rook_table + 40960, magic_rook_table + 45056, |
||
| 419 | magic_rook_table + 49152, magic_rook_table + 55296, |
||
| 420 | magic_rook_table + 79872, magic_rook_table + 98304 |
||
| 421 | }; |
||
| 422 | int16_t magic_rook_mobility_table[102400]; |
||
| 423 | int16_t *magic_rook_mobility_indices[64] = { |
||
| 424 | magic_rook_mobility_table + 86016, magic_rook_mobility_table + 73728, |
||
| 425 | magic_rook_mobility_table + 36864, magic_rook_mobility_table + 43008, |
||
| 426 | magic_rook_mobility_table + 47104, magic_rook_mobility_table + 51200, |
||
| 427 | magic_rook_mobility_table + 77824, magic_rook_mobility_table + 94208, |
||
| 428 | magic_rook_mobility_table + 69632, magic_rook_mobility_table + 32768, |
||
| 429 | magic_rook_mobility_table + 38912, magic_rook_mobility_table + 10240, |
||
| 430 | magic_rook_mobility_table + 14336, magic_rook_mobility_table + 53248, |
||
| 431 | magic_rook_mobility_table + 57344, magic_rook_mobility_table + 81920, |
||
| 432 | magic_rook_mobility_table + 24576, magic_rook_mobility_table + 33792, |
||
| 108 | pmbaty | 433 | magic_rook_mobility_table + 6144, magic_rook_mobility_table + 11264, |
| 33 | pmbaty | 434 | magic_rook_mobility_table + 15360, magic_rook_mobility_table + 18432, |
| 435 | magic_rook_mobility_table + 58368, magic_rook_mobility_table + 61440, |
||
| 108 | pmbaty | 436 | magic_rook_mobility_table + 26624, magic_rook_mobility_table + 4096, |
| 33 | pmbaty | 437 | magic_rook_mobility_table + 7168, magic_rook_mobility_table + 0, |
| 438 | magic_rook_mobility_table + 2048, magic_rook_mobility_table + 19456, |
||
| 439 | magic_rook_mobility_table + 22528, magic_rook_mobility_table + 63488, |
||
| 108 | pmbaty | 440 | magic_rook_mobility_table + 28672, magic_rook_mobility_table + 5120, |
| 441 | magic_rook_mobility_table + 8192, magic_rook_mobility_table + 1024, |
||
| 442 | magic_rook_mobility_table + 3072, magic_rook_mobility_table + 20480, |
||
| 443 | magic_rook_mobility_table + 23552, magic_rook_mobility_table + 65536, |
||
| 444 | magic_rook_mobility_table + 30720, magic_rook_mobility_table + 34816, |
||
| 154 | pmbaty | 445 | magic_rook_mobility_table + 9216, magic_rook_mobility_table + 12288, |
| 108 | pmbaty | 446 | magic_rook_mobility_table + 16384, magic_rook_mobility_table + 21504, |
| 33 | pmbaty | 447 | magic_rook_mobility_table + 59392, magic_rook_mobility_table + 67584, |
| 108 | pmbaty | 448 | magic_rook_mobility_table + 71680, magic_rook_mobility_table + 35840, |
| 449 | magic_rook_mobility_table + 39936, magic_rook_mobility_table + 13312, |
||
| 33 | pmbaty | 450 | magic_rook_mobility_table + 17408, magic_rook_mobility_table + 54272, |
| 451 | magic_rook_mobility_table + 60416, magic_rook_mobility_table + 83968, |
||
| 452 | magic_rook_mobility_table + 90112, magic_rook_mobility_table + 75776, |
||
| 453 | magic_rook_mobility_table + 40960, magic_rook_mobility_table + 45056, |
||
| 154 | pmbaty | 454 | magic_rook_mobility_table + 49152, magic_rook_mobility_table + 55296, |
| 455 | magic_rook_mobility_table + 79872, magic_rook_mobility_table + 98304 |
||
| 456 | }; |
||
| 457 | const uint64_t magic_rook[64] = { |
||
| 458 | 0x0080001020400080ull, 0x0040001000200040ull, 0x0080081000200080ull, |
||
| 459 | 0x0080040800100080ull, 0x0080020400080080ull, 0x0080010200040080ull, |
||
| 460 | 0x0080008001000200ull, 0x0080002040800100ull, 0x0000800020400080ull, |
||
| 33 | pmbaty | 461 | 0x0000400020005000ull, 0x0000801000200080ull, 0x0000800800100080ull, |
| 108 | pmbaty | 462 | 0x0000800400080080ull, 0x0000800200040080ull, 0x0000800100020080ull, |
| 463 | 0x0000800040800100ull, 0x0000208000400080ull, 0x0000404000201000ull, |
||
| 464 | 0x0000808010002000ull, 0x0000808008001000ull, 0x0000808004000800ull, |
||
| 465 | 0x0000808002000400ull, 0x0000010100020004ull, 0x0000020000408104ull, |
||
| 466 | 0x0000208080004000ull, 0x0000200040005000ull, 0x0000100080200080ull, |
||
| 467 | 0x0000080080100080ull, 0x0000040080080080ull, 0x0000020080040080ull, |
||
| 468 | 0x0000010080800200ull, 0x0000800080004100ull, 0x0000204000800080ull, |
||
| 469 | 0x0000200040401000ull, 0x0000100080802000ull, 0x0000080080801000ull, |
||
| 470 | 0x0000040080800800ull, 0x0000020080800400ull, 0x0000020001010004ull, |
||
| 33 | pmbaty | 471 | 0x0000800040800100ull, 0x0000204000808000ull, 0x0000200040008080ull, |
| 472 | 0x0000100020008080ull, 0x0000080010008080ull, 0x0000040008008080ull, |
||
| 473 | 0x0000020004008080ull, 0x0000010002008080ull, 0x0000004081020004ull, |
||
| 474 | 0x0000204000800080ull, 0x0000200040008080ull, 0x0000100020008080ull, |
||
| 475 | 0x0000080010008080ull, 0x0000040008008080ull, 0x0000020004008080ull, |
||
| 476 | 0x0000800100020080ull, 0x0000800041000080ull, 0x00FFFCDDFCED714Aull, |
||
| 477 | 0x007FFCDDFCED714Aull, 0x003FFFCDFFD88096ull, 0x0000040810002101ull, |
||
| 478 | 0x0001000204080011ull, 0x0001000204000801ull, 0x0001000082000401ull, |
||
| 154 | pmbaty | 479 | 0x0001FFFAABFAD1A2ull |
| 33 | pmbaty | 480 | }; |
| 481 | const uint64_t magic_rook_mask[64] = { |
||
| 482 | 0x000101010101017Eull, 0x000202020202027Cull, 0x000404040404047Aull, |
||
| 154 | pmbaty | 483 | 0x0008080808080876ull, 0x001010101010106Eull, 0x002020202020205Eull, |
| 33 | pmbaty | 484 | 0x004040404040403Eull, 0x008080808080807Eull, 0x0001010101017E00ull, |
| 485 | 0x0002020202027C00ull, 0x0004040404047A00ull, 0x0008080808087600ull, |
||
| 486 | 0x0010101010106E00ull, 0x0020202020205E00ull, 0x0040404040403E00ull, |
||
| 487 | 0x0080808080807E00ull, 0x00010101017E0100ull, 0x00020202027C0200ull, |
||
| 488 | 0x00040404047A0400ull, 0x0008080808760800ull, 0x00101010106E1000ull, |
||
| 108 | pmbaty | 489 | 0x00202020205E2000ull, 0x00404040403E4000ull, 0x00808080807E8000ull, |
| 33 | pmbaty | 490 | 0x000101017E010100ull, 0x000202027C020200ull, 0x000404047A040400ull, |
| 491 | 0x0008080876080800ull, 0x001010106E101000ull, 0x002020205E202000ull, |
||
| 108 | pmbaty | 492 | 0x004040403E404000ull, 0x008080807E808000ull, 0x0001017E01010100ull, |
| 493 | 0x0002027C02020200ull, 0x0004047A04040400ull, 0x0008087608080800ull, |
||
| 494 | 0x0010106E10101000ull, 0x0020205E20202000ull, 0x0040403E40404000ull, |
||
| 495 | 0x0080807E80808000ull, 0x00017E0101010100ull, 0x00027C0202020200ull, |
||
| 33 | pmbaty | 496 | 0x00047A0404040400ull, 0x0008760808080800ull, 0x00106E1010101000ull, |
| 497 | 0x00205E2020202000ull, 0x00403E4040404000ull, 0x00807E8080808000ull, |
||
| 498 | 0x007E010101010100ull, 0x007C020202020200ull, 0x007A040404040400ull, |
||
| 154 | pmbaty | 499 | 0x0076080808080800ull, 0x006E101010101000ull, 0x005E202020202000ull, |
| 33 | pmbaty | 500 | 0x003E404040404000ull, 0x007E808080808000ull, 0x7E01010101010100ull, |
| 501 | 0x7C02020202020200ull, 0x7A04040404040400ull, 0x7608080808080800ull, |
||
| 108 | pmbaty | 502 | 0x6E10101010101000ull, 0x5E20202020202000ull, 0x3E40404040404000ull, |
| 503 | 0x7E80808080808000ull |
||
| 504 | }; |
||
| 505 | const unsigned magic_rook_shift[64] = { |
||
| 506 | 52, 53, 53, 53, 53, 53, 53, 52, |
||
| 507 | 53, 54, 54, 54, 54, 54, 54, 53, |
||
| 508 | 53, 54, 54, 54, 54, 54, 54, 53, |
||
| 509 | 53, 54, 54, 54, 54, 54, 54, 53, |
||
| 510 | 53, 54, 54, 54, 54, 54, 54, 53, |
||
| 511 | 53, 54, 54, 54, 54, 54, 54, 53, |
||
| 512 | 53, 54, 54, 54, 54, 54, 54, 53, |
||
| 33 | pmbaty | 513 | 53, 54, 54, 53, 53, 53, 53, 53 |
| 108 | pmbaty | 514 | }; |
| 515 | const uint64_t mobility_mask_b[4] = { |
||
| 33 | pmbaty | 516 | 0xFF818181818181FFull, 0x007E424242427E00ull, |
| 517 | 0x00003C24243C0000ull, 0x0000001818000000ull |
||
| 518 | }; |
||
| 519 | const uint64_t mobility_mask_r[4] = { |
||
| 520 | 0x8181818181818181ull, 0x4242424242424242ull, |
||
| 521 | 0x2424242424242424ull, 0x1818181818181818ull |
||
| 522 | }; |
||
| 523 | /* |
||
| 524 | values use to deal with white/black independently |
||
| 525 | */ |
||
| 526 | const int rankflip[2][8] = { |
||
| 527 | {RANK8, RANK7, RANK6, RANK5, RANK4, RANK3, RANK2, RANK1}, |
||
| 528 | {RANK1, RANK2, RANK3, RANK4, RANK5, RANK6, RANK7, RANK8} |
||
| 529 | }; |
||
| 530 | const int sqflip[2][64] = { |
||
| 108 | pmbaty | 531 | {A8, B8, C8, D8, E8, F8, G8, H8, |
| 33 | pmbaty | 532 | A7, B7, C7, D7, E7, F7, G7, H7, |
| 533 | A6, B6, C6, D6, E6, F6, G6, H6, |
||
| 534 | A5, B5, C5, D5, E5, F5, G5, H5, |
||
| 535 | A4, B4, C4, D4, E4, F4, G4, H4, /* black */ |
||
| 536 | A3, B3, C3, D3, E3, F3, G3, H3, |
||
| 537 | A2, B2, C2, D2, E2, F2, G2, H2, |
||
| 538 | A1, B1, C1, D1, E1, F1, G1, H1}, |
||
| 108 | pmbaty | 539 | |
| 540 | {A1, B1, C1, D1, E1, F1, G1, H1, |
||
| 541 | A2, B2, C2, D2, E2, F2, G2, H2, |
||
| 33 | pmbaty | 542 | A3, B3, C3, D3, E3, F3, G3, H3, |
| 543 | A4, B4, C4, D4, E4, F4, G4, H4, |
||
| 544 | A5, B5, C5, D5, E5, F5, G5, H5, /* white */ |
||
| 545 | A6, B6, C6, D6, E6, F6, G6, H6, |
||
| 546 | A7, B7, C7, D7, E7, F7, G7, H7, |
||
| 547 | A8, B8, C8, D8, E8, F8, G8, H8} |
||
| 548 | }; |
||
| 156 | pmbaty | 549 | const int rank1[2] = {RANK8, RANK1}; |
| 550 | const int rank2[2] = {RANK7, RANK2}; |
||
| 551 | const int rank3[2] = {RANK6, RANK3}; |
||
| 33 | pmbaty | 552 | const int rank4[2] = {RANK5, RANK4}; |
| 553 | const int rank5[2] = {RANK4, RANK5}; |
||
| 554 | const int rank6[2] = {RANK3, RANK6}; |
||
| 555 | const int rank7[2] = {RANK2, RANK7}; |
||
| 556 | const int rank8[2] = {RANK1, RANK8}; |
||
| 108 | pmbaty | 557 | const int epdir[2] = {8, -8}; |
| 558 | const int csq[2] = {C8, C1}; |
||
| 33 | pmbaty | 559 | const int dsq[2] = {D8, D1}; |
| 560 | const int esq[2] = {E8, E1}; |
||
| 561 | const int fsq[2] = {F8, F1}; |
||
| 562 | const int gsq[2] = {G8, G1}; |
||
| 563 | uint64_t distance_ring[64][8]; |
||
| 564 | const int sign[2] = {-1, 1}; |
||
| 565 | const int epsq[2] = {+8, -8}; |
||
| 566 | const int rook_A[2] = {A8, A1}; |
||
| 108 | pmbaty | 567 | const int rook_D[2] = {D8, D1}; |
| 568 | const int rook_F[2] = {F8, F1}; |
||
| 569 | const int rook_G[2] = {G8, G1}; |
||
| 33 | pmbaty | 570 | const int rook_H[2] = {H8, H1}; |
| 571 | const int pawnadv1[2] = {+8, -8}; |
||
| 572 | const int pawnadv2[2] = {+16, -16}; |
||
| 108 | pmbaty | 573 | const int capleft[2] = {+9, -7}; |
| 33 | pmbaty | 574 | const int capright[2] = {+7, -9}; |
| 575 | const char empty_sqs[9] = {0, '1', '2', '3', '4', '5', '6', '7', '8'}; |
||
| 576 | const int pcval[7] = {0, 100, 300, 300, 500, 900, 9900}; |
||
| 577 | const int p_vals[7] = {0, 1, 3, 3, 5, 9, 99}; |
||
| 154 | pmbaty | 578 | const int MVV_LVA[7][7] = { |
| 156 | pmbaty | 579 | {0, 5<<21, 4<<21, 4<<21, 3<<21, 2<<21, 1<<21}, |
| 108 | pmbaty | 580 | {0, 10<<21, 9<<21, 9<<21, 8<<21, 7<<21, 6<<21}, |
| 581 | {0, 15<<21, 14<<21, 14<<21, 13<<21, 12<<21, 11<<21}, |
||
| 582 | {0, 15<<21, 14<<21, 14<<21, 13<<21, 12<<21, 11<<21}, |
||
| 583 | {0, 20<<21, 19<<21, 19<<21, 18<<21, 17<<21, 16<<21}, |
||
| 584 | {0, 25<<21, 24<<21, 24<<21, 23<<21, 22<<21, 21<<21}, |
||
| 154 | pmbaty | 585 | {0, 30<<21, 29<<21, 29<<21, 28<<21, 27<<21, 26<<21}}; |
| 108 | pmbaty | 586 | const int pieces[2][7] = { |
| 154 | pmbaty | 587 | {0, -1, -2, -3, -4, -5, -6}, |
| 588 | {0, +1, +2, +3, +4, +5, +6} |
||
| 589 | }; |
||
| 590 | const int lower_n = 16; |
||
| 108 | pmbaty | 591 | const int lower_b = 10; |
| 592 | const int mobility_score_n[4] = {1, 2, 3, 4}; |
||
| 593 | const int mobility_score_b[4] = {1, 2, 3, 4}; |
||
| 594 | const int mobility_score_r[4] = {1, 2, 3, 4}; |
||
| 595 | const int mob_curve_r[48] = { |
||
| 596 | -27,-23,-21,-19,-15,-10, -9, -8, |
||
| 597 | -7, -6, -5, -4, -3, -2, -1, 0, |
||
| 598 | 1, 2, 3, 4, 5, 6, 7, 8, |
||
| 599 | 9, 10, 11, 12, 13, 14, 15, 16, |
||
| 600 | 17, 18, 19, 20, 21, 22, 23, 24, |
||
| 601 | 25, 26, 27, 28, 29, 30, 31, 32 |
||
| 602 | }; |
||
| 603 | int piece_values[2][7] = { |
||
| 604 | {0, -PAWN_VALUE, -KNIGHT_VALUE, -BISHOP_VALUE, |
||
| 605 | -ROOK_VALUE, -QUEEN_VALUE, -KING_VALUE}, |
||
| 606 | {0, PAWN_VALUE, KNIGHT_VALUE, BISHOP_VALUE, |
||
| 607 | ROOK_VALUE, QUEEN_VALUE, KING_VALUE} |
||
| 608 | }; |
||
| 609 | /* |
||
| 610 | First term is a character string explaining what the eval |
||
| 611 | term is used for. |
||
| 612 | |||
| 613 | Second term is the "type" of the value. |
||
| 614 | 0 = heading entry (no values, just a category name to display). |
||
| 615 | 1 = scalar value. |
||
| 33 | pmbaty | 616 | 2 = array[mg] |
| 617 | 3 = floating point value |
||
| 618 | |||
| 619 | Third term is the "size" of the scoring term, where 0 is a |
||
| 108 | pmbaty | 620 | scalar value, otherwise it is the actual number of elements in |
| 621 | an array of values. |
||
| 33 | pmbaty | 622 | |
| 623 | Fourth term is a pointer to the data value(s). |
||
| 624 | */ |
||
| 625 | struct personality_term personality_packet[256] = { |
||
| 626 | {"search options ", 0, 0, NULL}, /* 0 */ |
||
| 627 | {"check extension ", 1, 0, &check_depth}, |
||
| 108 | pmbaty | 628 | {"null-move reduction ", 1, 0, &null_depth}, |
| 629 | {"null-move adaptive divisor ", 1, 0, &null_divisor}, |
||
| 630 | {"LMR min distance to frontier ", 1, 0, &LMR_rdepth}, |
||
| 631 | {"LMR min reduction ", 1, 0, &LMR_min}, |
||
| 632 | {"LMR max reduction ", 1, 0, &LMR_max}, |
||
| 633 | {"LMR formula depth bias ", 3, 0, &LMR_db}, |
||
| 634 | {"LMR formula moves searched bias ", 3, 0, &LMR_mb}, |
||
| 635 | {"LMR scale factor ", 3, 0, &LMR_s}, |
||
| 636 | {"search options (continued) ", 0, 0, NULL}, /* 10 */ |
||
| 637 | {NULL, 0, 0, NULL}, |
||
| 638 | }; |
||
| 639 | /* *INDENT-ON* */ |
||
| 640 | |||
| 641 |