]> git.sesse.net Git - stockfish/commitdiff
Remove global variables from search.h
authorMarco Costalba <mcostalba@gmail.com>
Thu, 11 Jun 2009 13:11:08 +0000 (15:11 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Fri, 12 Jun 2009 11:10:40 +0000 (13:10 +0200)
Globals are not really needed, so redefine as locals.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/search.cpp
src/search.h
src/uci.cpp

index 8021f0f57ed7e333fd213939ca12134756bef7bf..a40187b8024bfcda6b858045a7679a755e872ee1 100644 (file)
@@ -32,7 +32,9 @@
 #include "evaluate.h"
 #include "history.h"
 #include "misc.h"
+#include "movegen.h"
 #include "movepick.h"
+#include "lock.h"
 #include "san.h"
 #include "search.h"
 #include "thread.h"
@@ -243,10 +245,12 @@ namespace {
   std::ofstream LogFile;
 
   // MP related variables
+  int ActiveThreads = 1;
   Depth MinimumSplitDepth;
   int MaxThreadsPerSplitPoint;
   Thread Threads[THREAD_MAX];
   Lock MPLock;
+  Lock IOLock;
   bool AllThreadsShouldExit = false;
   const int MaxActiveSplitPoints = 8;
   SplitPoint SplitPointStack[THREAD_MAX][MaxActiveSplitPoints];
@@ -264,6 +268,9 @@ namespace {
   int NodesSincePoll;
   int NodesBetweenPolls = 30000;
 
+   // The main transposition table
+   TranspositionTable TT;
+
 
   /// Functions
 
@@ -316,39 +323,6 @@ namespace {
 }
 
 
-////
-//// Global variables
-////
-
-// The main transposition table
-TranspositionTable TT;
-
-
-// Number of active threads:
-int ActiveThreads = 1;
-
-// Locks.  In principle, there is no need for IOLock to be a global variable,
-// but it could turn out to be useful for debugging.
-Lock IOLock;
-
-
-// SearchStack::init() initializes a search stack. Used at the beginning of a
-// new search from the root.
-void SearchStack::init(int ply) {
-
-  pv[ply] = pv[ply + 1] = MOVE_NONE;
-  currentMove = threatMove = MOVE_NONE;
-  reduction = Depth(0);
-}
-
-void SearchStack::initKillers() {
-
-  mateKiller = MOVE_NONE;
-  for (int i = 0; i < KILLER_MAX; i++)
-      killers[i] = MOVE_NONE;
-}
-
-
 ////
 //// Functions
 ////
@@ -449,7 +423,7 @@ bool think(const Position &pos, bool infinite, bool ponder, int side_to_move,
       init_eval(ActiveThreads);
   }
 
-  // Wake up sleeping threads:
+  // Wake up sleeping threads
   wake_sleeping_threads();
 
   for (int i = 1; i < ActiveThreads; i++)
@@ -623,6 +597,22 @@ int64_t nodes_searched() {
 }
 
 
+// SearchStack::init() initializes a search stack. Used at the beginning of a
+// new search from the root.
+void SearchStack::init(int ply) {
+
+  pv[ply] = pv[ply + 1] = MOVE_NONE;
+  currentMove = threatMove = MOVE_NONE;
+  reduction = Depth(0);
+}
+
+void SearchStack::initKillers() {
+
+  mateKiller = MOVE_NONE;
+  for (int i = 0; i < KILLER_MAX; i++)
+      killers[i] = MOVE_NONE;
+}
+
 namespace {
 
   // id_loop() is the main iterative deepening loop.  It calls root_search
index 03c35f022d97cd2b5588c6947738ad2c663c2361..069bbdd26e1954d9a872e0f5ddbc5e8978bb9d76 100644 (file)
 ////
 
 #include "depth.h"
-#include "history.h"
-#include "lock.h"
-#include "movegen.h"
-#include "position.h"
-#include "tt.h"
-#include "value.h"
+#include "move.h"
 
 
 ////
@@ -65,15 +60,6 @@ struct SearchStack {
 };
 
 
-////
-//// Global variables
-////
-
-extern TranspositionTable TT;
-extern int ActiveThreads;
-extern Lock SMPLock;
-
-
 ////
 //// Prototypes
 ////
index 4a333f70b7540b2d660070bf6579cfaafaa5cc50..b3af1b607a24138d4a87d0b0f327472d9fe0b81d 100644 (file)
@@ -123,7 +123,7 @@ namespace {
     }
     else if (token == "ucinewgame")
     {
-        TT.clear();
+        push_button("Clear Hash");
         Position::init_piece_square_tables();
         RootPosition.from_fen(StartPosition);
     }