]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Retire notation.h
[stockfish] / src / search.cpp
index 1317fc239ddc46c22f89167b2516f645ed33aa13..a871626af4134cd07c6de8ed988a35d8e5a8cc0f 100644 (file)
 #include "evaluate.h"
 #include "movegen.h"
 #include "movepick.h"
-#include "notation.h"
 #include "rkiss.h"
 #include "search.h"
 #include "timeman.h"
 #include "thread.h"
 #include "tt.h"
-#include "ucioption.h"
+#include "uci.h"
 
 namespace Search {
 
@@ -126,6 +125,7 @@ void Search::init() {
   {
       double    pvRed = 0.00 + log(double(hd)) * log(double(mc)) / 3.00;
       double nonPVRed = 0.33 + log(double(hd)) * log(double(mc)) / 2.25;
+
       Reductions[1][1][hd][mc] = int8_t(   pvRed >= 1.0 ?    pvRed + 0.5: 0);
       Reductions[0][1][hd][mc] = int8_t(nonPVRed >= 1.0 ? nonPVRed + 0.5: 0);
 
@@ -139,8 +139,8 @@ void Search::init() {
   // Init futility move count array
   for (d = 0; d < 32; ++d)
   {
-      FutilityMoveCounts[0][d] = int(2.4 + 0.222 * pow(d * 2 + 0.00, 1.8));
-      FutilityMoveCounts[1][d] = int(3.0 + 0.300 * pow(d * 2 + 0.98, 1.8));
+      FutilityMoveCounts[0][d] = int(2.4 + 0.773 * pow(d + 0.00, 1.8));
+      FutilityMoveCounts[1][d] = int(2.9 + 1.045 * pow(d + 0.49, 1.8));
   }
 }
 
@@ -167,7 +167,7 @@ uint64_t Search::perft(Position& pos, Depth depth) {
           pos.undo_move(*it);
       }
       if (Root)
-          sync_cout << move_to_uci(*it, pos.is_chess960()) << ": " << cnt << sync_endl;
+          sync_cout << UCI::move_to_uci(*it, pos.is_chess960()) << ": " << cnt << sync_endl;
   }
   return nodes;
 }
@@ -191,7 +191,7 @@ void Search::think() {
   {
       RootMoves.push_back(MOVE_NONE);
       sync_cout << "info depth 0 score "
-                << score_to_uci(RootPos.checkers() ? -VALUE_MATE : VALUE_DRAW)
+                << UCI::score_to_uci(RootPos.checkers() ? -VALUE_MATE : VALUE_DRAW)
                 << sync_endl;
 
       goto finalize;
@@ -226,8 +226,8 @@ finalize:
   }
 
   // Best move could be MOVE_NONE when searching on a stalemate position
-  sync_cout << "bestmove " << move_to_uci(RootMoves[0].pv[0], RootPos.is_chess960())
-            << " ponder "  << move_to_uci(RootMoves[0].pv[1], RootPos.is_chess960())
+  sync_cout << "bestmove " << UCI::move_to_uci(RootMoves[0].pv[0], RootPos.is_chess960())
+            << " ponder "  << UCI::move_to_uci(RootMoves[0].pv[1], RootPos.is_chess960())
             << sync_endl;
 }
 
@@ -694,7 +694,7 @@ moves_loop: // When in check and at SpNode search starts from here
 
           if (thisThread == Threads.main() && Time::now() - SearchTime > 3000)
               sync_cout << "info depth " << depth
-                        << " currmove " << move_to_uci(move, pos.is_chess960())
+                        << " currmove " << UCI::move_to_uci(move, pos.is_chess960())
                         << " currmovenumber " << moveCount + PVIdx << sync_endl;
       }
 
@@ -787,6 +787,9 @@ moves_loop: // When in check and at SpNode search starts from here
           }
       }
 
+      // Speculative prefetch as early as possible
+      prefetch((char*)TT.first_entry(pos.key_after(move)));
+
       // Check for legality just before making the move
       if (!RootNode && !SpNode && !pos.legal(move, ci.pinned))
       {
@@ -1136,6 +1139,9 @@ moves_loop: // When in check and at SpNode search starts from here
           &&  pos.see_sign(move) < VALUE_ZERO)
           continue;
 
+      // Speculative prefetch as early as possible
+      prefetch((char*)TT.first_entry(pos.key_after(move)));
+
       // Check for legality just before making the move
       if (!pos.legal(move, ci.pinned))
           continue;
@@ -1320,7 +1326,7 @@ moves_loop: // When in check and at SpNode search starts from here
 
         ss << "info depth " << d
            << " seldepth "  << selDepth
-           << " score "     << (i == PVIdx ? score_to_uci(v, alpha, beta) : score_to_uci(v))
+           << " score "     << (i == PVIdx ? UCI::score_to_uci(v, alpha, beta) : UCI::score_to_uci(v))
            << " nodes "     << pos.nodes_searched()
            << " nps "       << pos.nodes_searched() * 1000 / elapsed
            << " time "      << elapsed
@@ -1328,7 +1334,7 @@ moves_loop: // When in check and at SpNode search starts from here
            << " pv";
 
         for (size_t j = 0; RootMoves[i].pv[j] != MOVE_NONE; ++j)
-            ss << " " << move_to_uci(RootMoves[i].pv[j], pos.is_chess960());
+            ss << " " << UCI::move_to_uci(RootMoves[i].pv[j], pos.is_chess960());
     }
 
     return ss.str();