1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 08:43:09 +00:00

Remove global variables from search.h

Globals are not really needed, so redefine as locals.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2009-06-11 15:11:08 +02:00
parent 3e0753bef3
commit d2c2af9e1c
3 changed files with 26 additions and 50 deletions

View 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

View file

@ -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
////

View 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);
}