1
0
Fork 0

Use DEPTH_ZERO initializer for depth in qsearch (#931)

Simplifies the main search function.

No functional change.
pull/913/merge
Joost VandeVondele 2016-12-20 11:17:38 +01:00 committed by Marco Costalba
parent 8c61bbda54
commit ee22b61f5e
1 changed files with 10 additions and 11 deletions

View File

@ -165,7 +165,7 @@ namespace {
Value search(Position& pos, Stack* ss, Value alpha, Value beta, Depth depth, bool cutNode, bool skipEarlyPruning);
template <NodeType NT, bool InCheck>
Value qsearch(Position& pos, Stack* ss, Value alpha, Value beta, Depth depth);
Value qsearch(Position& pos, Stack* ss, Value alpha, Value beta, Depth depth = DEPTH_ZERO);
Value value_to_tt(Value v, int ply);
Value value_from_tt(Value v, int ply);
@ -721,10 +721,10 @@ namespace {
&& eval + razor_margin[depth / ONE_PLY] <= alpha)
{
if (depth <= ONE_PLY)
return qsearch<NonPV, false>(pos, ss, alpha, beta, DEPTH_ZERO);
return qsearch<NonPV, false>(pos, ss, alpha, beta);
Value ralpha = alpha - razor_margin[depth / ONE_PLY];
Value v = qsearch<NonPV, false>(pos, ss, ralpha, ralpha+1, DEPTH_ZERO);
Value v = qsearch<NonPV, false>(pos, ss, ralpha, ralpha+1);
if (v <= ralpha)
return v;
}
@ -752,7 +752,7 @@ namespace {
Depth R = ((823 + 67 * depth / ONE_PLY) / 256 + std::min((eval - beta) / PawnValueMg, 3)) * ONE_PLY;
pos.do_null_move(st);
nullValue = depth-R < ONE_PLY ? -qsearch<NonPV, false>(pos, ss+1, -beta, -beta+1, DEPTH_ZERO)
nullValue = depth-R < ONE_PLY ? -qsearch<NonPV, false>(pos, ss+1, -beta, -beta+1)
: - search<NonPV>(pos, ss+1, -beta, -beta+1, depth-R, !cutNode, true);
pos.undo_null_move();
@ -766,7 +766,7 @@ namespace {
return nullValue;
// Do verification search at high depths
Value v = depth-R < ONE_PLY ? qsearch<NonPV, false>(pos, ss, beta-1, beta, DEPTH_ZERO)
Value v = depth-R < ONE_PLY ? qsearch<NonPV, false>(pos, ss, beta-1, beta)
: search<NonPV>(pos, ss, beta-1, beta, depth-R, false, true);
if (v >= beta)
@ -1009,8 +1009,8 @@ moves_loop: // When in check search starts from here
// Step 16. Full depth search when LMR is skipped or fails high
if (doFullDepthSearch)
value = newDepth < ONE_PLY ?
givesCheck ? -qsearch<NonPV, true>(pos, ss+1, -(alpha+1), -alpha, DEPTH_ZERO)
: -qsearch<NonPV, false>(pos, ss+1, -(alpha+1), -alpha, DEPTH_ZERO)
givesCheck ? -qsearch<NonPV, true>(pos, ss+1, -(alpha+1), -alpha)
: -qsearch<NonPV, false>(pos, ss+1, -(alpha+1), -alpha)
: - search<NonPV>(pos, ss+1, -(alpha+1), -alpha, newDepth, !cutNode, false);
// For PV nodes only, do a full PV search on the first move or after a fail
@ -1022,8 +1022,8 @@ moves_loop: // When in check search starts from here
(ss+1)->pv[0] = MOVE_NONE;
value = newDepth < ONE_PLY ?
givesCheck ? -qsearch<PV, true>(pos, ss+1, -beta, -alpha, DEPTH_ZERO)
: -qsearch<PV, false>(pos, ss+1, -beta, -alpha, DEPTH_ZERO)
givesCheck ? -qsearch<PV, true>(pos, ss+1, -beta, -alpha)
: -qsearch<PV, false>(pos, ss+1, -beta, -alpha)
: - search<PV>(pos, ss+1, -beta, -alpha, newDepth, false, false);
}
@ -1147,8 +1147,7 @@ moves_loop: // When in check search starts from here
// qsearch() is the quiescence search function, which is called by the main
// search function when the remaining depth is zero (or, to be more precise,
// less than ONE_PLY).
// search function with depth zero, or recursively with depth less than ONE_PLY.
template <NodeType NT, bool InCheck>
Value qsearch(Position& pos, Stack* ss, Value alpha, Value beta, Depth depth) {