X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=4d1a6af784d1e41217df9b29c3676c20a55dc6cd;hp=95f99d0177e960dc3b4fd7e6f6c2b5ce634a2acc;hb=cedbd3332a4a1574e701bda098a9df1153e299c6;hpb=d471c49700fbe828159ba54a97946979f41500ae diff --git a/src/search.cpp b/src/search.cpp index 95f99d01..4d1a6af7 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -78,11 +78,6 @@ namespace { : 2 * VALUE_INFINITE; } - inline int futility_move_count(Depth d) { - - return d < 16 * ONE_PLY ? FutilityMoveCounts[d] : MAX_MOVES; - } - // Reduction lookup tables (initialized at startup) and their access function int8_t Reductions[2][64][64]; // [pv][depth][moveNumber] @@ -204,6 +199,8 @@ void Search::think() { Position& pos = RootPosition; Chess960 = pos.is_chess960(); Eval::RootColor = pos.side_to_move(); + Eval::ValueDraw[ Eval::RootColor] = VALUE_DRAW - Eval::ContemptFactor; + Eval::ValueDraw[~Eval::RootColor] = VALUE_DRAW + Eval::ContemptFactor; TimeMgr.init(Limits, pos.startpos_ply_counter(), pos.side_to_move()); TT.new_search(); H.clear(); @@ -543,7 +540,7 @@ namespace { { // Step 2. Check for aborted search and immediate draw if (Signals.stop || pos.is_draw() || ss->ply > MAX_PLY) - return Eval::ValueDrawContempt; + return Eval::ValueDraw[pos.side_to_move()]; // Step 3. Mate distance pruning. Even if we mate at the next move our score // would be at best mate_in(ss->ply+1), but if alpha is already bigger because @@ -640,10 +637,10 @@ namespace { && !ss->skipNullMove && depth < 4 * ONE_PLY && !inCheck - && refinedValue - futility_margin(depth, 0) >= beta + && refinedValue - FutilityMargins[depth][0] >= beta && abs(beta) < VALUE_MATE_IN_MAX_PLY && pos.non_pawn_material(pos.side_to_move())) - return refinedValue - futility_margin(depth, 0); + return refinedValue - FutilityMargins[depth][0]; // Step 8. Null move search with verification search (is omitted in PV nodes) if ( !PvNode @@ -768,7 +765,7 @@ split_point_start: // At split points actual search starts from here // Step 11. Loop through moves // Loop through all pseudo-legal moves until no moves remain or a beta cutoff occurs - while (bestValue < beta && (move = mp.next_move()) != MOVE_NONE) + while ((move = mp.next_move()) != MOVE_NONE) { assert(is_ok(move)); @@ -849,7 +846,8 @@ split_point_start: // At split points actual search starts from here && (bestValue > VALUE_MATED_IN_MAX_PLY || bestValue == -VALUE_INFINITE)) { // Move count based pruning - if ( moveCount >= futility_move_count(depth) + if ( depth < 16 * ONE_PLY + && moveCount >= FutilityMoveCounts[depth] && (!threatMove || !connected_threat(pos, move, threatMove))) { if (SpNode) @@ -981,23 +979,23 @@ split_point_start: // At split points actual search starts from here if (value > bestValue) { bestValue = value; + if (SpNode) sp->bestValue = value; if (value > alpha) { bestMove = move; + if (SpNode) sp->bestMove = move; if (PvNode && value < beta) - alpha = bestValue; // Update alpha here! Always alpha < beta - } - - if (SpNode) - { - sp->bestValue = bestValue; - sp->bestMove = bestMove; - sp->alpha = alpha; - - if (bestValue >= beta) - sp->cutoff = true; + { + alpha = value; // Update alpha here! Always alpha < beta + if (SpNode) sp->alpha = alpha; + } + else // Fail high + { + if (SpNode) sp->cutoff = true; + break; + } } } @@ -1006,8 +1004,11 @@ split_point_start: // At split points actual search starts from here && depth >= Threads.min_split_depth() && bestValue < beta && Threads.available_slave_exists(thisThread)) + { bestValue = Threads.split(pos, ss, alpha, beta, bestValue, &bestMove, depth, threatMove, moveCount, mp, NT); + break; + } } if (SpNode) @@ -1095,7 +1096,7 @@ split_point_start: // At split points actual search starts from here // Check for an instant draw or maximum ply reached if (pos.is_draw() || ss->ply > MAX_PLY) - return Eval::ValueDrawContempt; + return Eval::ValueDraw[pos.side_to_move()]; // Decide whether or not to include checks, this fixes also the type of // TT entry depth that we are going to use. Note that in qsearch we use