X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=61d0c4b2aaaadc36880ba5e59bcd00a8c58358dc;hp=0ccf326698ee3bc9a1a676e8831ba3e8001d39b2;hb=9a10313a9d72c16c90b46187ee41988abdfe1d86;hpb=28933a580eeb4b9a2d717f06c789a6c13dfef19c diff --git a/src/search.cpp b/src/search.cpp index 0ccf3266..61d0c4b2 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -256,8 +256,9 @@ void MainThread::search() { } else { - if (TB::Cardinality >= rootPos.count(WHITE) - + rootPos.count(BLACK)) + if ( TB::Cardinality >= rootPos.count(WHITE) + + rootPos.count(BLACK) + && !rootPos.can_castle(ANY_CASTLING)) { // If the current root position is in the tablebases, then RootMoves // contains only moves that preserve the draw or the win. @@ -352,6 +353,33 @@ void MainThread::search() { std::cout << sync_endl; } +const int halfDensityMap[][9] = +{ + {2, 0, 1}, + {2, 1, 0}, + + {4, 0, 0, 1, 1}, + {4, 0, 1, 1, 0}, + {4, 1, 1, 0, 0}, + {4, 1, 0, 0, 1}, + + {6, 0, 0, 0, 1, 1, 1}, + {6, 0, 0, 1, 1, 1, 0}, + {6, 0, 1, 1, 1, 0, 0}, + {6, 1, 1, 1, 0, 0, 0}, + {6, 1, 1, 0, 0, 0, 1}, + {6, 1, 0, 0, 0, 1, 1}, + + {8, 0, 0, 0, 0, 1, 1, 1, 1}, + {8, 0, 0, 0, 1, 1, 1, 1, 0}, + {8, 0, 0, 1, 1, 1, 1, 0 ,0}, + {8, 0, 1, 1, 1, 1, 0, 0 ,0}, + {8, 1, 1, 1, 1, 0, 0, 0 ,0}, + {8, 1, 1, 1, 0, 0, 0, 0 ,1}, + {8, 1, 1, 0, 0, 0, 0, 1 ,1}, + {8, 1, 0, 0, 0, 0, 1, 1 ,1}, +}; + // Thread::search() is the main iterative deepening loop. It calls search() // repeatedly with increasing depth until the allocated thinking time has been @@ -393,27 +421,12 @@ void Thread::search() { while (++rootDepth < DEPTH_MAX && !Signals.stop && (!Limits.depth || rootDepth <= Limits.depth)) { // Set up the new depths for the helper threads skipping on average every - // 2nd ply (using a half-density map similar to a Hadamard matrix). + // 2nd ply (using a half-density matrix). if (!mainThread) { - int d = rootDepth + rootPos.game_ply(); - - if (idx <= 6 || idx > 24) - { - if (((d + idx) >> (msb(idx + 1) - 1)) % 2) - continue; - } - else - { - // Table of values of 6 bits with 3 of them set - static const int HalfDensityMap[] = { - 0x07, 0x0b, 0x0d, 0x0e, 0x13, 0x16, 0x19, 0x1a, 0x1c, - 0x23, 0x25, 0x26, 0x29, 0x2c, 0x31, 0x32, 0x34, 0x38 - }; - - if ((HalfDensityMap[idx - 7] >> (d % 6)) & 1) - continue; - } + int row = (idx - 1) % 20; + if (halfDensityMap[row][(rootDepth + rootPos.game_ply()) % halfDensityMap[row][0] + 1]) + continue; } // Age out PV variability metric @@ -691,7 +704,8 @@ namespace { if ( piecesCnt <= TB::Cardinality && (piecesCnt < TB::Cardinality || depth >= TB::ProbeDepth) - && pos.rule50_count() == 0) + && pos.rule50_count() == 0 + && !pos.can_castle(ANY_CASTLING)) { int found, v = Tablebases::probe_wdl(pos, &found);