1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 08:43:09 +00:00

Synchronize search_pv() with search take II

No functional change

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Joona Kiiski 2010-02-24 14:05:31 +02:00 committed by Marco Costalba
parent 0980f43ab0
commit 3c31776a20

View file

@ -1123,7 +1123,7 @@ namespace {
moveIsCheck = pos.move_is_check(move, ci);
captureOrPromotion = pos.move_is_capture_or_promotion(move);
// Decide the new search depth
// Step 11. Decide the new search depth
ext = extension(pos, move, true, captureOrPromotion, moveIsCheck, singleEvasion, mateThreat, &dangerous);
// Singular extension search. We extend the TT move if its value is much better than
@ -1149,17 +1149,21 @@ namespace {
newDepth = depth - OnePly + ext;
// Update current move
// Update current move (this must be done after singular extension search)
movesSearched[moveCount++] = ss[ply].currentMove = move;
// Make and search the move
// Step 12. Futility pruning (is omitted in PV nodes)
// Step 13. Make the move
pos.do_move(move, st, ci, moveIsCheck);
if (moveCount == 1) // The first move in list is the PV
// Step extra. pv search (only in PV nodes)
// The first move in list is the expected PV
if (moveCount == 1)
value = -search_pv(pos, ss, -beta, -alpha, newDepth, ply+1, threadID);
else
{
// Try to reduce non-pv search depth by one ply if move seems not problematic,
// Step 14. Reduced search
// if the move fails high will be re-searched at full depth.
bool doFullDepthSearch = true;
@ -1177,19 +1181,24 @@ namespace {
}
}
if (doFullDepthSearch) // Go with full depth non-pv search
// Step 15. Full depth search
if (doFullDepthSearch)
{
ss[ply].reduction = Depth(0);
value = -search(pos, ss, -alpha, newDepth, ply+1, true, threadID);
// Step extra. pv search (only in PV nodes)
if (value > alpha && value < beta)
value = -search_pv(pos, ss, -beta, -alpha, newDepth, ply+1, threadID);
}
}
// Step 16. Undo move
pos.undo_move(move);
assert(value > -VALUE_INFINITE && value < VALUE_INFINITE);
// New best move?
// Step 17. Check for new best move
if (value > bestValue)
{
bestValue = value;
@ -1202,7 +1211,7 @@ namespace {
}
}
// Split?
// Step 18. Check for split
if ( TM.active_threads() > 1
&& bestValue < beta
&& depth >= MinimumSplitDepth
@ -1215,11 +1224,13 @@ namespace {
break;
}
// All legal moves have been searched. A special case: If there were
// Step 19. Check for mate and stalemate
// All legal moves have been searched and if there were
// no legal moves, it must be mate or stalemate.
if (moveCount == 0)
return (isCheck ? value_mated_in(ply) : VALUE_DRAW);
// Step 20. Update tables
// If the search is not aborted, update the transposition table,
// history counters, and killer moves.
if (AbortSearch || TM.thread_should_stop(threadID))