From 4ad6a3496b4ab2234e1a2436116be827be2d3a20 Mon Sep 17 00:00:00 2001 From: Joona Kiiski Date: Tue, 12 Jul 2011 02:00:30 +0300 Subject: [PATCH] Move the draw check also for qsearch Signed-off-by: Marco Costalba --- src/search.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/search.cpp b/src/search.cpp index 33e170ac..e7933f76 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -1322,10 +1322,6 @@ undo: ss->bestMove = ss->currentMove = MOVE_NONE; ss->ply = (ss-1)->ply + 1; - // Check for an instant draw or maximum ply reached - if (pos.is_draw() || ss->ply > PLY_MAX) - return VALUE_DRAW; - // Decide whether or not to include checks, this fixes also the type of // TT entry depth that we are going to use. Note that in qsearch we use // only two types of depth in TT: DEPTH_QS_CHECKS or DEPTH_QS_NO_CHECKS. @@ -1460,7 +1456,12 @@ undo: // Make and search the move pos.do_move(move, st, ci, givesCheck); - value = -qsearch(pos, ss+1, -beta, -alpha, depth-ONE_PLY); + + if (pos.is_draw() || ss->ply+1 > PLY_MAX) + value = VALUE_DRAW; + else + value = -qsearch(pos, ss+1, -beta, -alpha, depth-ONE_PLY); + pos.undo_move(move); assert(value > -VALUE_INFINITE && value < VALUE_INFINITE); -- 2.39.2