mirror of
https://github.com/sockspls/badfish
synced 2025-05-01 01:03: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:
parent
3e0753bef3
commit
d2c2af9e1c
3 changed files with 26 additions and 50 deletions
|
@ -32,7 +32,9 @@
|
||||||
#include "evaluate.h"
|
#include "evaluate.h"
|
||||||
#include "history.h"
|
#include "history.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
#include "movegen.h"
|
||||||
#include "movepick.h"
|
#include "movepick.h"
|
||||||
|
#include "lock.h"
|
||||||
#include "san.h"
|
#include "san.h"
|
||||||
#include "search.h"
|
#include "search.h"
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
|
@ -243,10 +245,12 @@ namespace {
|
||||||
std::ofstream LogFile;
|
std::ofstream LogFile;
|
||||||
|
|
||||||
// MP related variables
|
// MP related variables
|
||||||
|
int ActiveThreads = 1;
|
||||||
Depth MinimumSplitDepth;
|
Depth MinimumSplitDepth;
|
||||||
int MaxThreadsPerSplitPoint;
|
int MaxThreadsPerSplitPoint;
|
||||||
Thread Threads[THREAD_MAX];
|
Thread Threads[THREAD_MAX];
|
||||||
Lock MPLock;
|
Lock MPLock;
|
||||||
|
Lock IOLock;
|
||||||
bool AllThreadsShouldExit = false;
|
bool AllThreadsShouldExit = false;
|
||||||
const int MaxActiveSplitPoints = 8;
|
const int MaxActiveSplitPoints = 8;
|
||||||
SplitPoint SplitPointStack[THREAD_MAX][MaxActiveSplitPoints];
|
SplitPoint SplitPointStack[THREAD_MAX][MaxActiveSplitPoints];
|
||||||
|
@ -264,6 +268,9 @@ namespace {
|
||||||
int NodesSincePoll;
|
int NodesSincePoll;
|
||||||
int NodesBetweenPolls = 30000;
|
int NodesBetweenPolls = 30000;
|
||||||
|
|
||||||
|
// The main transposition table
|
||||||
|
TranspositionTable TT;
|
||||||
|
|
||||||
|
|
||||||
/// Functions
|
/// 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
|
//// Functions
|
||||||
////
|
////
|
||||||
|
@ -449,7 +423,7 @@ bool think(const Position &pos, bool infinite, bool ponder, int side_to_move,
|
||||||
init_eval(ActiveThreads);
|
init_eval(ActiveThreads);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wake up sleeping threads:
|
// Wake up sleeping threads
|
||||||
wake_sleeping_threads();
|
wake_sleeping_threads();
|
||||||
|
|
||||||
for (int i = 1; i < ActiveThreads; i++)
|
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 {
|
namespace {
|
||||||
|
|
||||||
// id_loop() is the main iterative deepening loop. It calls root_search
|
// id_loop() is the main iterative deepening loop. It calls root_search
|
||||||
|
|
16
src/search.h
16
src/search.h
|
@ -26,12 +26,7 @@
|
||||||
////
|
////
|
||||||
|
|
||||||
#include "depth.h"
|
#include "depth.h"
|
||||||
#include "history.h"
|
#include "move.h"
|
||||||
#include "lock.h"
|
|
||||||
#include "movegen.h"
|
|
||||||
#include "position.h"
|
|
||||||
#include "tt.h"
|
|
||||||
#include "value.h"
|
|
||||||
|
|
||||||
|
|
||||||
////
|
////
|
||||||
|
@ -65,15 +60,6 @@ struct SearchStack {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
////
|
|
||||||
//// Global variables
|
|
||||||
////
|
|
||||||
|
|
||||||
extern TranspositionTable TT;
|
|
||||||
extern int ActiveThreads;
|
|
||||||
extern Lock SMPLock;
|
|
||||||
|
|
||||||
|
|
||||||
////
|
////
|
||||||
//// Prototypes
|
//// Prototypes
|
||||||
////
|
////
|
||||||
|
|
|
@ -123,7 +123,7 @@ namespace {
|
||||||
}
|
}
|
||||||
else if (token == "ucinewgame")
|
else if (token == "ucinewgame")
|
||||||
{
|
{
|
||||||
TT.clear();
|
push_button("Clear Hash");
|
||||||
Position::init_piece_square_tables();
|
Position::init_piece_square_tables();
|
||||||
RootPosition.from_fen(StartPosition);
|
RootPosition.from_fen(StartPosition);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue