mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 00:33:09 +00:00
Retire init_node()
Also don't poll in qsearch() No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
05c5f08372
commit
9b17083912
1 changed files with 14 additions and 38 deletions
|
@ -296,7 +296,6 @@ namespace {
|
||||||
template <NodeType PvNode>
|
template <NodeType PvNode>
|
||||||
Depth extension(const Position& pos, Move m, bool captureOrPromotion, bool moveIsCheck, bool singleEvasion, bool mateThreat, bool* dangerous);
|
Depth extension(const Position& pos, Move m, bool captureOrPromotion, bool moveIsCheck, bool singleEvasion, bool mateThreat, bool* dangerous);
|
||||||
|
|
||||||
void init_node(SearchStack* ss, int ply, int threadID);
|
|
||||||
void update_pv(SearchStack* ss, int ply);
|
void update_pv(SearchStack* ss, int ply);
|
||||||
void sp_update_pv(SearchStack* pss, SearchStack* ss, int ply);
|
void sp_update_pv(SearchStack* pss, SearchStack* ss, int ply);
|
||||||
bool connected_moves(const Position& pos, Move m1, Move m2);
|
bool connected_moves(const Position& pos, Move m1, Move m2);
|
||||||
|
@ -1060,9 +1059,16 @@ namespace {
|
||||||
if (depth < OnePly)
|
if (depth < OnePly)
|
||||||
return qsearch<PvNode>(pos, ss, alpha, beta, Depth(0), threadID);
|
return qsearch<PvNode>(pos, ss, alpha, beta, Depth(0), threadID);
|
||||||
|
|
||||||
// Step 1. Initialize node and poll
|
// Step 1. Initialize node and poll. Polling can abort search
|
||||||
// Polling can abort search.
|
TM.incrementNodeCounter(threadID);
|
||||||
init_node(ss, ply, threadID);
|
ss->init(ply);
|
||||||
|
(ss + 2)->initKillers();
|
||||||
|
|
||||||
|
if (threadID == 0 && ++NodesSincePoll > NodesBetweenPolls)
|
||||||
|
{
|
||||||
|
NodesSincePoll = 0;
|
||||||
|
poll();
|
||||||
|
}
|
||||||
|
|
||||||
// Step 2. Check for aborted search and immediate draw
|
// Step 2. Check for aborted search and immediate draw
|
||||||
if (AbortSearch || TM.thread_should_stop(threadID))
|
if (AbortSearch || TM.thread_should_stop(threadID))
|
||||||
|
@ -1446,14 +1452,10 @@ namespace {
|
||||||
int ply = pos.ply();
|
int ply = pos.ply();
|
||||||
Value oldAlpha = alpha;
|
Value oldAlpha = alpha;
|
||||||
|
|
||||||
// Initialize, and make an early exit in case of an aborted search,
|
TM.incrementNodeCounter(threadID);
|
||||||
// an instant draw, maximum ply reached, etc.
|
ss->init(ply);
|
||||||
init_node(ss, ply, threadID);
|
|
||||||
|
|
||||||
// After init_node() that calls poll()
|
|
||||||
if (AbortSearch || TM.thread_should_stop(threadID))
|
|
||||||
return Value(0);
|
|
||||||
|
|
||||||
|
// Check for an instant draw or maximum ply reached
|
||||||
if (pos.is_draw() || ply >= PLY_MAX - 1)
|
if (pos.is_draw() || ply >= PLY_MAX - 1)
|
||||||
return VALUE_DRAW;
|
return VALUE_DRAW;
|
||||||
|
|
||||||
|
@ -1771,32 +1773,6 @@ namespace {
|
||||||
lock_release(&(sp->lock));
|
lock_release(&(sp->lock));
|
||||||
}
|
}
|
||||||
|
|
||||||
// init_node() is called at the beginning of all the search functions
|
|
||||||
// (search() qsearch(), and so on) and initializes the
|
|
||||||
// search stack object corresponding to the current node. Once every
|
|
||||||
// NodesBetweenPolls nodes, init_node() also calls poll(), which polls
|
|
||||||
// for user input and checks whether it is time to stop the search.
|
|
||||||
|
|
||||||
void init_node(SearchStack* ss, int ply, int threadID) {
|
|
||||||
|
|
||||||
assert(ply >= 0 && ply < PLY_MAX);
|
|
||||||
assert(threadID >= 0 && threadID < TM.active_threads());
|
|
||||||
|
|
||||||
TM.incrementNodeCounter(threadID);
|
|
||||||
|
|
||||||
if (threadID == 0)
|
|
||||||
{
|
|
||||||
NodesSincePoll++;
|
|
||||||
if (NodesSincePoll >= NodesBetweenPolls)
|
|
||||||
{
|
|
||||||
poll();
|
|
||||||
NodesSincePoll = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ss->init(ply);
|
|
||||||
(ss + 2)->initKillers();
|
|
||||||
}
|
|
||||||
|
|
||||||
// update_pv() is called whenever a search returns a value > alpha.
|
// update_pv() is called whenever a search returns a value > alpha.
|
||||||
// It updates the PV in the SearchStack object corresponding to the
|
// It updates the PV in the SearchStack object corresponding to the
|
||||||
// current node.
|
// current node.
|
||||||
|
@ -2530,7 +2506,7 @@ namespace {
|
||||||
|
|
||||||
// Wait for thread termination
|
// Wait for thread termination
|
||||||
for (int i = 1; i < MAX_THREADS; i++)
|
for (int i = 1; i < MAX_THREADS; i++)
|
||||||
while (threads[i].state != THREAD_TERMINATED);
|
while (threads[i].state != THREAD_TERMINATED) {}
|
||||||
|
|
||||||
// Now we can safely destroy the locks
|
// Now we can safely destroy the locks
|
||||||
for (int i = 0; i < MAX_THREADS; i++)
|
for (int i = 0; i < MAX_THREADS; i++)
|
||||||
|
|
Loading…
Add table
Reference in a new issue