Merge official-stockfish/master
authorFabian Fichter <ianfab@users.noreply.github.com>
Thu, 3 Sep 2020 22:32:10 +0000 (00:32 +0200)
committerFabian Fichter <ianfab@users.noreply.github.com>
Thu, 3 Sep 2020 22:32:10 +0000 (00:32 +0200)
bench: 4379669

1  2 
src/misc.h
src/psqt.cpp
src/search.cpp
src/tt.cpp
src/tt.h
src/ucioption.cpp

diff --cc src/misc.h
Simple merge
diff --cc src/psqt.cpp
Simple merge
diff --cc src/search.cpp
@@@ -433,7 -403,7 +433,7 @@@ void Thread::search() 
            if (rootDepth >= 4)
            {
                Value prev = rootMoves[pvIdx].previousScore;
-               delta = Value(21 * (1 + rootPos.captures_to_hand()));
 -              delta = Value(19);
++              delta = Value(19 * (1 + rootPos.captures_to_hand()));
                alpha = std::max(prev - delta,-VALUE_INFINITE);
                beta  = std::min(prev + delta, VALUE_INFINITE);
  
@@@ -891,20 -819,18 +891,20 @@@ namespace 
      // Step 9. Null move search with verification search (~40 Elo)
      if (   !PvNode
          && (ss-1)->currentMove != MOVE_NULL
-         && (ss-1)->statScore < 23397
+         && (ss-1)->statScore < 23824
          &&  eval >= beta
          &&  eval >= ss->staticEval
-         &&  ss->staticEval >= beta - 32 * depth - 30 * improving + 120 * ttPv + 292
+         &&  ss->staticEval >= beta - 33 * depth - 33 * improving + 112 * ttPv + 311
          && !excludedMove
          &&  pos.non_pawn_material(us)
 +        &&  pos.count<ALL_PIECES>(~us) != pos.count<PAWN>(~us)
 +        && !pos.flip_enclosed_pieces()
          && (ss->ply >= thisThread->nmpMinPly || us != thisThread->nmpColor))
      {
          assert(eval - beta >= 0);
  
          // Null move dynamic reduction based on depth and value
-         Depth R = (854 - 150 * !pos.checking_permitted() + 68 * depth) / 258 + std::min(int(eval - beta) / 192, 3);
 -        Depth R = (737 + 77 * depth) / 246 + std::min(int(eval - beta) / 192, 3);
++        Depth R = (737 - 150 * !pos.checking_permitted() + 77 * depth) / 246 + std::min(int(eval - beta) / 192, 3);
  
          ss->currentMove = MOVE_NULL;
          ss->continuationHistory = &thisThread->continuationHistory[0][0][NO_PIECE][0];
      // If we have a good enough capture and a reduced search returns a value
      // much above beta, we can (almost) safely prune the previous move.
      if (   !PvNode
-         &&  depth >= 5
+         &&  depth > 4
          &&  abs(beta) < VALUE_TB_WIN_IN_MAX_PLY)
      {
-         Value raisedBeta = beta + (189 + 20 * !!pos.capture_the_flag_piece()) * (1 + pos.check_counting() + (pos.extinction_value() != VALUE_NONE)) - 45 * improving;
 -        Value raisedBeta = beta + 176 - 49 * improving;
++        Value raisedBeta = beta + (176 + 20 * !!pos.capture_the_flag_piece()) * (1 + pos.check_counting() + (pos.extinction_value() != VALUE_NONE)) - 49 * improving;
          assert(raisedBeta < VALUE_INFINITE);
          MovePicker mp(pos, ttMove, raisedBeta - ss->staticEval, &captureHistory);
          int probCutCount = 0;
@@@ -1079,20 -1003,18 +1079,20 @@@ moves_loop: // When in check, search st
                // Futility pruning: parent node (~5 Elo)
                if (   lmrDepth < 6
                    && !ss->inCheck
 -                  && ss->staticEval + 284 + 188 * lmrDepth <= alpha
 -                  &&  (*contHist[0])[movedPiece][to_sq(move)]
 -                    + (*contHist[1])[movedPiece][to_sq(move)]
 -                    + (*contHist[3])[movedPiece][to_sq(move)]
 -                    + (*contHist[5])[movedPiece][to_sq(move)] / 2 < 28388)
 +                  && !(   pos.extinction_value() == -VALUE_MATE
 +                       && pos.extinction_piece_types().find(ALL_PIECES) == pos.extinction_piece_types().end())
-                   && ss->staticEval + (235 + 172 * lmrDepth) * (1 + pos.check_counting()) <= alpha
++                  && ss->staticEval + (284 + 188 * lmrDepth) * (1 + pos.check_counting()) <= alpha
 +                  &&  (*contHist[0])[history_slot(movedPiece)][to_sq(move)]
 +                    + (*contHist[1])[history_slot(movedPiece)][to_sq(move)]
 +                    + (*contHist[3])[history_slot(movedPiece)][to_sq(move)]
-                     + (*contHist[5])[history_slot(movedPiece)][to_sq(move)] / 2 < 31400)
++                    + (*contHist[5])[history_slot(movedPiece)][to_sq(move)] / 2 < 28388)
                    continue;
  
                // Prune moves with negative SEE (~20 Elo)
-               if (!pos.see_ge(move, Value(-(32 - std::min(lmrDepth, 18) + 10 * !!pos.capture_the_flag_piece()) * lmrDepth * lmrDepth)))
 -              if (!pos.see_ge(move, Value(-(29 - std::min(lmrDepth, 17)) * lmrDepth * lmrDepth)))
++              if (!pos.see_ge(move, Value(-(29 - std::min(lmrDepth, 17) + 10 * !!pos.capture_the_flag_piece()) * lmrDepth * lmrDepth)))
                    continue;
            }
 -          else
 +          else if (!pos.must_capture())
            {
                // Capture history based pruning when the move doesn't give check
                if (   !givesCheck
                    continue;
  
                // See based pruning
-               if (!pos.see_ge(move, Value(-194 - 120 * pos.captures_to_hand()) * depth)) // (~25 Elo)
 -              if (!pos.see_ge(move, Value(-202) * depth)) // (~25 Elo)
++              if (!pos.see_ge(move, Value(-202 - 120 * pos.captures_to_hand()) * depth)) // (~25 Elo)
                    continue;
            }
        }
                || moveCountPruning
                || ss->staticEval + PieceValue[EG][pos.captured_piece()] <= alpha
                || cutNode
-               || thisThread->ttHitAverage < 375 * TtHitAverageResolution * TtHitAverageWindow / 1024)
 -              || thisThread->ttHitAverage < 415 * TtHitAverageResolution * TtHitAverageWindow / 1024))
++              || thisThread->ttHitAverage < 415 * TtHitAverageResolution * TtHitAverageWindow / 1024)
 +          && !(pos.must_capture() && MoveList<CAPTURES>(pos).size()))
        {
            Depth r = reduction(improving, depth, moveCount);
  
                // hence break make_move(). (~2 Elo)
                else if (    type_of(move) == NORMAL
                         && !pos.see_ge(reverse_move(move)))
-                   r -= 2 + ttPv;
+                   r -= 2 + ttPv - (type_of(movedPiece) == PAWN);
  
                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;
+                              - 4826;
  
                // Decrease/increase reduction by comparing opponent's stat score (~10 Elo)
-               if (ss->statScore >= -102 && (ss-1)->statScore < -114)
+               if (ss->statScore >= -100 && (ss-1)->statScore < -112)
                    r--;
  
-               else if ((ss-1)->statScore >= -116 && ss->statScore < -154)
+               else if ((ss-1)->statScore >= -125 && ss->statScore < -138)
                    r++;
  
                // Decrease/increase reduction for moves with a good/bad history (~30 Elo)
-               r -= ss->statScore / (16434 - 4434 * pos.captures_to_hand());
 -              r -= ss->statScore / 14615;
++              r -= ss->statScore / (14615 - 4434 * pos.captures_to_hand());
            }
            else
            {
diff --cc src/tt.cpp
@@@ -36,11 -36,11 +36,11 @@@ TranspositionTable TT; // Our global tr
  void TTEntry::save(Key k, Value v, bool pv, Bound b, Depth d, Move m, Value ev) {
  
    // Preserve any existing move for the same position
-   if (m || (k >> 48) != key16)
+   if (m || (uint16_t)k != key16)
 -      move16 = (uint16_t)m;
 +      move32 = (uint32_t)m;
  
    // Overwrite less valuable entries
-   if (  (k >> 48) != key16
+   if ((uint16_t)k != key16
        || d - DEPTH_OFFSET > depth8 - 4
        || b == BOUND_EXACT)
    {
diff --cc src/tt.h
+++ b/src/tt.h
@@@ -65,8 -65,7 +65,7 @@@ private
  
  class TranspositionTable {
  
 -  static constexpr int ClusterSize = 3;
 +  static constexpr int ClusterSize = 5;
-   static constexpr int ClustersPerSuperCluster = 256;
  
    struct Cluster {
      TTEntry entry[ClusterSize];
@@@ -136,13 -56,11 +136,12 @@@ bool CaseInsensitiveLess::operator() (c
  
  void init(OptionsMap& o) {
  
-   // At most 2^32 superclusters. Supercluster = 8 kB
    constexpr int MaxHashMB = Is64Bit ? 33554432 : 2048;
  
 +  o["Protocol"]              << Option("uci", {"uci", "usi", "ucci", "xboard"});
    o["Debug Log File"]        << Option("", on_logger);
    o["Contempt"]              << Option(24, -100, 100);
 -  o["Analysis Contempt"]     << Option("Both var Off var White var Black var Both", "Both");
 +  o["Analysis Contempt"]     << Option("Both", {"Both", "Off", "White", "Black"});
    o["Threads"]               << Option(1, 1, 512, on_threads);
    o["Hash"]                  << Option(16, 1, MaxHashMB, on_hash_size);
    o["Clear Hash"]            << Option(on_clear_hash);