1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-29 16:23:09 +00:00

Sync sp_search() with main search()

And fix qserahc() dispatch also there.

No functional change tested wit Faked Split.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2010-06-02 10:49:34 +01:00
parent 5212995563
commit c6ba14b7c9

View file

@ -1673,9 +1673,9 @@ namespace {
// Step 12. Futility pruning (is omitted in PV nodes) // Step 12. Futility pruning (is omitted in PV nodes)
if ( !PvNode if ( !PvNode
&& !isCheck
&& !dangerous
&& !captureOrPromotion && !captureOrPromotion
&& !isCheck
&& !dangerous
&& !move_is_castle(move)) && !move_is_castle(move))
{ {
// Move count based pruning // Move count based pruning
@ -1709,16 +1709,18 @@ namespace {
// If the move fails high will be re-searched at full depth. // If the move fails high will be re-searched at full depth.
bool doFullDepthSearch = true; bool doFullDepthSearch = true;
if ( !dangerous if ( !captureOrPromotion
&& !captureOrPromotion && !dangerous
&& !move_is_castle(move) && !move_is_castle(move)
&& !move_is_killer(move, ss)) && !move_is_killer(move, ss))
{ {
ss->reduction = reduction<PvNode>(sp->depth, moveCount); ss->reduction = reduction<PvNode>(sp->depth, moveCount);
if (ss->reduction) if (ss->reduction)
{ {
Value localAlpha = sp->alpha; Value localAlpha = sp->alpha;
value = -search<NonPV>(pos, ss+1, -(localAlpha+1), -localAlpha, newDepth-ss->reduction, true, threadID); Depth d = newDepth - ss->reduction;
value = d < OnePly ? -qsearch<NonPV>(pos, ss+1, -(localAlpha+1), -localAlpha, Depth(0), threadID)
: - search<NonPV>(pos, ss+1, -(localAlpha+1), -localAlpha, d, true, threadID);
doFullDepthSearch = (value > localAlpha); doFullDepthSearch = (value > localAlpha);
} }
@ -1727,6 +1729,8 @@ namespace {
// if the move fails high again then go with full depth search. // if the move fails high again then go with full depth search.
if (doFullDepthSearch && ss->reduction > 2 * OnePly) if (doFullDepthSearch && ss->reduction > 2 * OnePly)
{ {
assert(newDepth - OnePly >= OnePly);
ss->reduction = OnePly; ss->reduction = OnePly;
Value localAlpha = sp->alpha; Value localAlpha = sp->alpha;
value = -search<NonPV>(pos, ss+1, -(localAlpha+1), -localAlpha, newDepth-ss->reduction, true, threadID); value = -search<NonPV>(pos, ss+1, -(localAlpha+1), -localAlpha, newDepth-ss->reduction, true, threadID);
@ -1739,10 +1743,15 @@ namespace {
{ {
ss->reduction = Depth(0); ss->reduction = Depth(0);
Value localAlpha = sp->alpha; Value localAlpha = sp->alpha;
value = -search<NonPV>(pos, ss+1, -(localAlpha+1), -localAlpha, newDepth, true, threadID); value = newDepth < OnePly ? -qsearch<NonPV>(pos, ss+1, -(localAlpha+1), -localAlpha, Depth(0), threadID)
: - search<NonPV>(pos, ss+1, -(localAlpha+1), -localAlpha, newDepth, true, threadID);
// Step extra. pv search (only in PV nodes)
// Search only for possible new PV nodes, if instead value >= beta then
// parent node fails low with value <= alpha and tries another move.
if (PvNode && value > localAlpha && value < sp->beta) if (PvNode && value > localAlpha && value < sp->beta)
value = -search<PV>(pos, ss+1, -sp->beta, -sp->alpha, newDepth, false, threadID); value = newDepth < OnePly ? -qsearch<PV>(pos, ss+1, -sp->beta, -sp->alpha, Depth(0), threadID)
: - search<PV>(pos, ss+1, -sp->beta, -sp->alpha, newDepth, false, threadID);
} }
// Step 16. Undo move // Step 16. Undo move