From: Fabian Fichter Date: Sun, 18 Jul 2021 11:51:44 +0000 (+0200) Subject: Merge official-stockfish/master X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=7f1aec180d581120fc6ecf56679256ba1a2e67d5;p=fairystockfish.git Merge official-stockfish/master bench: 4890740 --- 7f1aec180d581120fc6ecf56679256ba1a2e67d5 diff --cc src/evaluate.cpp index 8ec699e,0e66fea..53b8f3d --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@@ -241,14 -214,13 +241,13 @@@ using namespace Trace namespace { // Threshold for lazy and space evaluation - constexpr Value LazyThreshold1 = Value(1565); - constexpr Value LazyThreshold2 = Value(1102); - constexpr Value SpaceThreshold = Value(11551); - constexpr Value NNUEThreshold1 = Value(682); - constexpr Value NNUEThreshold2 = Value(176); + constexpr Value LazyThreshold1 = Value(1565); + constexpr Value LazyThreshold2 = Value(1102); + constexpr Value SpaceThreshold = Value(11551); + constexpr Value NNUEThreshold1 = Value(800); // KingAttackWeights[PieceType] contains king attack weights by piece type - constexpr int KingAttackWeights[PIECE_TYPE_NB] = { 0, 0, 81, 52, 44, 10 }; + constexpr int KingAttackWeights[PIECE_TYPE_NB] = { 0, 0, 81, 52, 44, 10, 40 }; // SafeCheck[PieceType][single/multiple] contains safe check bonus by piece type, // higher if multiple safe checks are possible for that piece type. @@@ -1614,31 -1126,14 +1613,15 @@@ Value Eval::evaluate(const Position& po return nnue; }; - // If there is PSQ imbalance we use the classical eval. We also introduce - // a small probability of using the classical eval when PSQ imbalance is small. + // If there is PSQ imbalance we use the classical eval. Value psq = Value(abs(eg_value(pos.psq_score()))); int r50 = 16 + pos.rule50_count(); - bool largePsq = psq * 16 > (NNUEThreshold1 + pos.non_pawn_material() / 64) * r50; + bool pure = !pos.check_counting(); + bool largePsq = psq * 16 > (NNUEThreshold1 + pos.non_pawn_material() / 64) * r50 && !pure; - bool classical = largePsq; - - // Use classical evaluation for really low piece endgames. - // One critical case is the draw for bishop + A/H file pawn vs naked king. - bool lowPieceEndgame = pos.non_pawn_material() == BishopValueMg - || (pos.non_pawn_material() < 2 * RookValueMg && pos.count() < 2); - - v = classical || lowPieceEndgame ? Evaluation(pos).value() - : adjusted_NNUE(); - - // If the classical eval is small and imbalance large, use NNUE nevertheless. - // For the case of opposite colored bishops, switch to NNUE eval with small - // probability if the classical eval is less than the threshold. - if ( largePsq - && !lowPieceEndgame - && ( abs(v) * 16 < NNUEThreshold2 * r50 - || ( pos.opposite_bishops() - && abs(v) * 16 < (NNUEThreshold1 + pos.non_pawn_material() / 64) * r50))) - v = adjusted_NNUE(); + + v = largePsq ? Evaluation(pos).value() // classical + : adjusted_NNUE(); // NNUE + } // Damp down the evaluation linearly when shuffling diff --cc src/nnue/nnue_feature_transformer.h index 0a50f87,c249d3e..4333039 --- a/src/nnue/nnue_feature_transformer.h +++ b/src/nnue/nnue_feature_transformer.h @@@ -166,8 -163,10 +164,10 @@@ namespace Stockfish::Eval::NNUE bool write_parameters(std::ostream& stream) const { for (std::size_t i = 0; i < HalfDimensions; ++i) write_little_endian(stream, biases[i]); - for (std::size_t i = 0; i < HalfDimensions * InputDimensions; ++i) + for (std::size_t i = 0; i < HalfDimensions * FeatureSet::get_dimensions(); ++i) write_little_endian(stream, weights[i]); - for (std::size_t i = 0; i < PSQTBuckets * InputDimensions; ++i) ++ for (std::size_t i = 0; i < PSQTBuckets * FeatureSet::get_dimensions(); ++i) + write_little_endian(stream, psqtWeights[i]); return !stream.fail(); } diff --cc src/search.cpp index e258648,100ddc7..f61dc9e --- a/src/search.cpp +++ b/src/search.cpp @@@ -1240,13 -1098,11 +1241,17 @@@ moves_loop: // When in check, search st return beta; } } + else if ( givesCheck + && depth > 6 + && abs(ss->staticEval) > Value(100)) + extension = 1; + // Losing chess capture extension + else if ( pos.must_capture() + && pos.capture(move) + && (ss->inCheck || MoveList(pos).size() == 1)) + extension = 1; + // Add extension to new depth newDepth += extension; @@@ -1267,10 -1125,9 +1272,10 @@@ // cases where we extend a son if it has good chances to be "interesting". if ( depth >= 3 && moveCount > 1 + 2 * rootNode + && !(pos.must_capture() && pos.has_capture()) && ( !captureOrPromotion - || cutNode - || (!PvNode && !formerPv)) + || (cutNode && (ss-1)->moveCount > 1) + || !ss->ttPv) && (!PvNode || ss->ply > 1 || thisThread->id() % 4 != 3)) { Depth r = reduction(improving, depth, moveCount); @@@ -1305,14 -1166,10 +1314,10 @@@ if (ttCapture) r++; - // Increase reduction for cut nodes (~3 Elo) - if (cutNode) - r += 2; - 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)] - 4923; // Decrease/increase reduction for moves with a good/bad history (~30 Elo)