From d2c2af9e1c4f5711e320555fe31ae4ed940802c6 Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Thu, 11 Jun 2009 15:11:08 +0200 Subject: [PATCH] Remove global variables from search.h Globals are not really needed, so redefine as locals. No functional change. Signed-off-by: Marco Costalba --- src/search.cpp | 58 +++++++++++++++++++++----------------------------- src/search.h | 16 +------------- src/uci.cpp | 2 +- 3 files changed, 26 insertions(+), 50 deletions(-) diff --git a/src/search.cpp b/src/search.cpp index 8021f0f5..a40187b8 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -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 diff --git a/src/search.h b/src/search.h index 03c35f02..069bbdd2 100644 --- a/src/search.h +++ b/src/search.h @@ -26,12 +26,7 @@ //// #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 //// diff --git a/src/uci.cpp b/src/uci.cpp index 4a333f70..b3af1b60 100644 --- a/src/uci.cpp +++ b/src/uci.cpp @@ -123,7 +123,7 @@ namespace { } else if (token == "ucinewgame") { - TT.clear(); + push_button("Clear Hash"); Position::init_piece_square_tables(); RootPosition.from_fen(StartPosition); } -- 2.39.2