]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Implement init_search()
[stockfish] / src / search.cpp
index 4eabb59f385ce597707139544c861008778b0a83..c13431bc9721d418b1eabded12b677df2bb7ba23 100644 (file)
@@ -527,21 +527,13 @@ bool think(const Position& pos, bool infinite, bool ponder, int side_to_move,
 }
 
 
 }
 
 
-/// init_threads() is called during startup. It launches all helper threads,
-/// and initializes the split point stack and the global locks and condition
-/// objects.
+/// init_search() is called during startup. It initializes various
+/// lookup tables.
 
 
-void init_threads() {
-
-  volatile int i;
-  bool ok;
-
-#if !defined(_MSC_VER)
-  pthread_t pthread[1];
-#endif
+void init_search() {
 
   // Init our reduction lookup tables
 
   // Init our reduction lookup tables
-  for (i = 1; i < 64; i++) // i == depth
+  for (int i = 1; i < 64; i++) // i == depth (OnePly = 1)
       for (int j = 1; j < 64; j++) // j == moveNumber
       {
           double    pvRed = 0.5 + log(double(i)) * log(double(j)) / 6.0;
       for (int j = 1; j < 64; j++) // j == moveNumber
       {
           double    pvRed = 0.5 + log(double(i)) * log(double(j)) / 6.0;
@@ -551,15 +543,30 @@ void init_threads() {
       }
 
   // Init futility margins array
       }
 
   // Init futility margins array
-  for (i = 0; i < 14; i++) // i == depth (OnePly = 2)
+  for (int i = 0; i < 14; i++) // i == depth (OnePly = 2)
       for (int j = 0; j < 64; j++) // j == moveNumber
       {
           FutilityMarginsMatrix[i][j] = (i < 2 ? 0 : 112 * bitScanReverse32(i * i / 2)) - 8 * j; // FIXME: test using log instead of BSR
       }
 
   // Init futility move count array
       for (int j = 0; j < 64; j++) // j == moveNumber
       {
           FutilityMarginsMatrix[i][j] = (i < 2 ? 0 : 112 * bitScanReverse32(i * i / 2)) - 8 * j; // FIXME: test using log instead of BSR
       }
 
   // Init futility move count array
-  for (i = 0; i < 32; i++) // i == depth (OnePly = 2)
+  for (int i = 0; i < 32; i++) // i == depth (OnePly = 2)
       FutilityMoveCountArray[i] = 3 + (1 << (3 * i / 8));
       FutilityMoveCountArray[i] = 3 + (1 << (3 * i / 8));
+}
+
+
+/// init_threads() is called during startup. It launches all helper threads,
+/// and initializes the split point stack and the global locks and condition
+/// objects.
+
+void init_threads() {
+
+  volatile int i;
+  bool ok;
+
+#if !defined(_MSC_VER)
+  pthread_t pthread[1];
+#endif
 
   for (i = 0; i < THREAD_MAX; i++)
       Threads[i].activeSplitPoints = 0;
 
   for (i = 0; i < THREAD_MAX; i++)
       Threads[i].activeSplitPoints = 0;