From: Fabian Fichter Date: Sun, 31 May 2020 23:01:24 +0000 (+0200) Subject: Merge official-stockfish/master X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=53a18c8231568628c753827d95663ce83feada9f;p=fairystockfish.git Merge official-stockfish/master bench: 4755489 --- 53a18c8231568628c753827d95663ce83feada9f diff --cc src/evaluate.cpp index 9763547,be39f8a..d123f0c --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@@ -179,9 -167,8 +179,9 @@@ namespace template Score threats() const; template Score passed() const; template Score space() const; + template Score variant() const; ScaleFactor scale_factor(Value eg) const; - Score initiative(Score score) const; + Score initiative(Score score, Score materialScore) const; const Position& pos; Material::Entry* me; @@@ -1000,21 -696,13 +1000,18 @@@ // known attacking/defending status of the players. template - Score Evaluation::initiative(Score score) const { - - Value mg = mg_value(score); - Value eg = eg_value(score); + Score Evaluation::initiative(Score score, Score materialScore) const { - int outflanking = distance(pos.square(WHITE), pos.square(BLACK)) - - distance(pos.square(WHITE), pos.square(BLACK)); + // No initiative bonus for extinction variants + if (pos.extinction_value() != VALUE_NONE || pos.captures_to_hand() || pos.connect_n()) + return SCORE_ZERO; - bool infiltration = rank_of(pos.square(WHITE)) > RANK_4 - || rank_of(pos.square(BLACK)) < RANK_5; + int outflanking = !pos.count(WHITE) || !pos.count(BLACK) ? 0 + : distance(pos.square(WHITE), pos.square(BLACK)) + - distance(pos.square(WHITE), pos.square(BLACK)); + + bool infiltration = (pos.count(WHITE) && rank_of(pos.square(WHITE)) > RANK_4) + || (pos.count(BLACK) && rank_of(pos.square(BLACK)) < RANK_5); bool pawnsOnBothFlanks = (pos.pieces(PAWN) & QueenSide) && (pos.pieces(PAWN) & KingSide); @@@ -1104,9 -791,12 +1106,12 @@@ // Early exit if score is high Value v = (mg_value(score) + eg_value(score)) / 2; - if (abs(v) > LazyThreshold + pos.non_pawn_material() / 64) + if (abs(v) > LazyThreshold + pos.non_pawn_material() / 64 && Options["UCI_Variant"] == "chess") return pos.side_to_move() == WHITE ? v : -v; + // Remember this score + Score materialScore = score; + // Main evaluation begins here initialize(); @@@ -1128,10 -813,9 +1133,10 @@@ score += king< WHITE>() - king< BLACK>() + threats() - threats() + passed< WHITE>() - passed< BLACK>() - + space< WHITE>() - space< BLACK>(); + + space< WHITE>() - space< BLACK>() + + variant() - variant(); - score += initiative(score); + score += initiative(score, materialScore); // Interpolate between a middlegame and a (scaled by 'sf') endgame score ScaleFactor sf = scale_factor(eg_value(score)); diff --cc src/search.cpp index a781aad,1490a26..14e53d6 --- a/src/search.cpp +++ b/src/search.cpp @@@ -886,13 -825,9 +886,13 @@@ namespace && eval <= alpha - RazorMargin) return qsearch(pos, ss, alpha, beta); - improving = (ss-2)->staticEval == VALUE_NONE ? (ss->staticEval >= (ss-4)->staticEval - || (ss-4)->staticEval == VALUE_NONE) : ss->staticEval >= (ss-2)->staticEval; + improving = (ss-2)->staticEval == VALUE_NONE ? (ss->staticEval > (ss-4)->staticEval + || (ss-4)->staticEval == VALUE_NONE) : ss->staticEval > (ss-2)->staticEval; + // Skip early pruning in case of mandatory capture + if (pos.must_capture() && MoveList(pos).size()) + goto moves_loop; + // Step 8. Futility pruning: child node (~50 Elo) if ( !PvNode && depth < 6 @@@ -1102,8 -1027,12 +1102,12 @@@ moves_loop: // When in check, search st if (!pos.see_ge(move, Value(-(32 - std::min(lmrDepth, 18)) * lmrDepth * lmrDepth))) continue; } - else if (!pos.see_ge(move, Value(-194) * depth)) // (~25 Elo) + else if (!pos.see_ge(move, Value(-194 - 120 * pos.captures_to_hand()) * depth)) // (~25 Elo) - continue; + { + if (captureOrPromotion && captureCount < 32) + capturesSearched[captureCount++] = move; + continue; + } } // Step 14. Extensions (~75 Elo) @@@ -1242,12 -1164,12 +1246,12 @@@ // hence break make_move(). (~2 Elo) else if ( type_of(move) == NORMAL && !pos.see_ge(reverse_move(move))) - r -= 2; + r -= 2 + ttPv; ss->statScore = thisThread->mainHistory[us][from_to(move)] - + (*contHist[0])[movedPiece][to_sq(move)] - + (*contHist[1])[movedPiece][to_sq(move)] - + (*contHist[3])[movedPiece][to_sq(move)] + + (*contHist[0])[history_slot(movedPiece)][to_sq(move)] + + (*contHist[1])[history_slot(movedPiece)][to_sq(move)] + + (*contHist[3])[history_slot(movedPiece)][to_sq(move)] - 4926; // Reset statScore to zero if negative and most stats shows >= 0