From 2d0146fe1d4551642f98c3273d26192b43e80d79 Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Fri, 19 Dec 2008 10:47:40 +0100 Subject: [PATCH] Call poll() before to check for stopped search Signed-off-by: Marco Costalba --- src/search.cpp | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/search.cpp b/src/search.cpp index 054ef45d..d89779f8 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -940,16 +940,17 @@ namespace { assert(ply >= 0 && ply < PLY_MAX); assert(threadID >= 0 && threadID < ActiveThreads); - // Initialize, and make an early exit in case of an aborted search, - // an instant draw, maximum ply reached, etc. - if (AbortSearch || thread_should_stop(threadID)) - return Value(0); - if (depth < OnePly) return qsearch(pos, ss, alpha, beta, Depth(0), ply, threadID); + // Initialize, and make an early exit in case of an aborted search, + // an instant draw, maximum ply reached, etc. init_node(pos, ss, ply, threadID); + // After init_node() that calls poll() + if (AbortSearch || thread_should_stop(threadID)) + return Value(0); + if (pos.is_draw()) return VALUE_DRAW; @@ -1132,21 +1133,22 @@ namespace { assert(ply >= 0 && ply < PLY_MAX); assert(threadID >= 0 && threadID < ActiveThreads); - EvalInfo ei; + if (depth < OnePly) + return qsearch(pos, ss, beta-1, beta, Depth(0), ply, threadID); // Initialize, and make an early exit in case of an aborted search, // an instant draw, maximum ply reached, etc. + init_node(pos, ss, ply, threadID); + + // After init_node() that calls poll() if (AbortSearch || thread_should_stop(threadID)) return Value(0); - if (depth < OnePly) - return qsearch(pos, ss, beta-1, beta, Depth(0), ply, threadID); - - init_node(pos, ss, ply, threadID); - if (pos.is_draw()) return VALUE_DRAW; + EvalInfo ei; + if (ply >= PLY_MAX - 1) return evaluate(pos, ei, threadID); @@ -1189,8 +1191,8 @@ namespace { Value nullValue = -search(pos, ss, -(beta-1), depth-R*OnePly, ply+1, false, threadID); // Check for a null capture artifact, if the value without the null capture - // is above beta then there is a good possibility that this is a cut-node. - // We will do an IID later to find a ttMove. + // is above beta then mark the node as a suspicious failed low. We will verify + // later if we are really under threat. if ( UseNullDrivenIID && nullValue < beta && depth > 6 * OnePly @@ -1256,7 +1258,9 @@ namespace { { // The null move failed low due to a suspicious capture. Perhaps we // are facing a null capture artifact due to the side to move change - // and this is a cut-node. So it's a good time to search for a ttMove. + // and this position should fail high. So do a normal search with a + // reduced depth to get a good ttMove to use in the following full + // depth search. Move tm = ss[ply].threatMove; assert(tm != MOVE_NONE); @@ -1419,15 +1423,14 @@ namespace { assert(ply >= 0 && ply < PLY_MAX); assert(threadID >= 0 && threadID < ActiveThreads); - EvalInfo ei; - // Initialize, and make an early exit in case of an aborted search, // an instant draw, maximum ply reached, etc. + init_node(pos, ss, ply, threadID); + + // After init_node() that calls poll() if (AbortSearch || thread_should_stop(threadID)) return Value(0); - init_node(pos, ss, ply, threadID); - if (pos.is_draw()) return VALUE_DRAW; @@ -1437,6 +1440,7 @@ namespace { return value_from_tt(tte->value(), ply); // Evaluate the position statically + EvalInfo ei; bool isCheck = pos.is_check(); Value staticValue = (isCheck ? -VALUE_INFINITE : evaluate(pos, ei, threadID)); -- 2.39.2