1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-07-11 19:49:14 +00:00

Clean-up code indentation in qsearch

closes https://github.com/official-stockfish/Stockfish/pull/4615

No functional change
This commit is contained in:
Stéphane Nicolet 2023-06-12 23:26:42 +02:00 committed by Joost VandeVondele
parent ece90bca9c
commit 92c949e12e

View file

@ -1481,10 +1481,11 @@ moves_loop: // When in check, search starts here
bestValue = ttValue; bestValue = ttValue;
} }
else else
{
// In case of null move search use previous static eval with a different sign // In case of null move search use previous static eval with a different sign
ss->staticEval = bestValue = ss->staticEval = bestValue = (ss-1)->currentMove != MOVE_NULL ? evaluate(pos)
(ss-1)->currentMove != MOVE_NULL ? evaluate(pos) : -(ss-1)->staticEval;
: -(ss-1)->staticEval; }
// Stand pat. Return immediately if static value is at least beta // Stand pat. Return immediately if static value is at least beta
if (bestValue >= beta) if (bestValue >= beta)
@ -1523,97 +1524,98 @@ moves_loop: // When in check, search starts here
// or a beta cutoff occurs. // or a beta cutoff occurs.
while ((move = mp.next_move()) != MOVE_NONE) while ((move = mp.next_move()) != MOVE_NONE)
{ {
assert(is_ok(move)); assert(is_ok(move));
// Check for legality // Check for legality
if (!pos.legal(move)) if (!pos.legal(move))
continue; continue;
givesCheck = pos.gives_check(move); givesCheck = pos.gives_check(move);
capture = pos.capture_stage(move); capture = pos.capture_stage(move);
moveCount++; moveCount++;
// Step 6. Pruning. // Step 6. Pruning.
if (bestValue > VALUE_TB_LOSS_IN_MAX_PLY) if (bestValue > VALUE_TB_LOSS_IN_MAX_PLY)
{ {
// Futility pruning and moveCount pruning (~10 Elo) // Futility pruning and moveCount pruning (~10 Elo)
if ( !givesCheck if ( !givesCheck
&& to_sq(move) != prevSq && to_sq(move) != prevSq
&& futilityBase > -VALUE_KNOWN_WIN && futilityBase > -VALUE_KNOWN_WIN
&& type_of(move) != PROMOTION) && type_of(move) != PROMOTION)
{ {
if (moveCount > 2) if (moveCount > 2)
continue; continue;
futilityValue = futilityBase + PieceValue[EG][pos.piece_on(to_sq(move))]; futilityValue = futilityBase + PieceValue[EG][pos.piece_on(to_sq(move))];
if (futilityValue <= alpha) if (futilityValue <= alpha)
{ {
bestValue = std::max(bestValue, futilityValue); bestValue = std::max(bestValue, futilityValue);
continue; continue;
} }
if (futilityBase <= alpha && !pos.see_ge(move, VALUE_ZERO + 1)) if (futilityBase <= alpha && !pos.see_ge(move, VALUE_ZERO + 1))
{ {
bestValue = std::max(bestValue, futilityBase); bestValue = std::max(bestValue, futilityBase);
continue; continue;
} }
} }
// We prune after 2nd quiet check evasion where being 'in check' is implicitly checked through the counter // We prune after the second quiet check evasion move, where being 'in check' is
// and being a 'quiet' apart from being a tt move is assumed after an increment because captures are pushed ahead. // implicitly checked through the counter, and being a 'quiet move' apart from
if (quietCheckEvasions > 1) // being a tt move is assumed after an increment because captures are pushed ahead.
break; if (quietCheckEvasions > 1)
break;
// Continuation history based pruning (~3 Elo) // Continuation history based pruning (~3 Elo)
if ( !capture if ( !capture
&& (*contHist[0])[pos.moved_piece(move)][to_sq(move)] < 0 && (*contHist[0])[pos.moved_piece(move)][to_sq(move)] < 0
&& (*contHist[1])[pos.moved_piece(move)][to_sq(move)] < 0) && (*contHist[1])[pos.moved_piece(move)][to_sq(move)] < 0)
continue; continue;
// Do not search moves with bad enough SEE values (~5 Elo) // Do not search moves with bad enough SEE values (~5 Elo)
if (!pos.see_ge(move, Value(-95))) if (!pos.see_ge(move, Value(-95)))
continue; continue;
} }
// Speculative prefetch as early as possible // Speculative prefetch as early as possible
prefetch(TT.first_entry(pos.key_after(move))); prefetch(TT.first_entry(pos.key_after(move)));
// Update the current move // Update the current move
ss->currentMove = move; ss->currentMove = move;
ss->continuationHistory = &thisThread->continuationHistory[ss->inCheck] ss->continuationHistory = &thisThread->continuationHistory[ss->inCheck]
[capture] [capture]
[pos.moved_piece(move)] [pos.moved_piece(move)]
[to_sq(move)]; [to_sq(move)];
quietCheckEvasions += !capture && ss->inCheck; quietCheckEvasions += !capture && ss->inCheck;
// Step 7. Make and search the move // Step 7. Make and search the move
pos.do_move(move, st, givesCheck); pos.do_move(move, st, givesCheck);
value = -qsearch<nodeType>(pos, ss+1, -beta, -alpha, depth - 1); value = -qsearch<nodeType>(pos, ss+1, -beta, -alpha, depth - 1);
pos.undo_move(move); pos.undo_move(move);
assert(value > -VALUE_INFINITE && value < VALUE_INFINITE); assert(value > -VALUE_INFINITE && value < VALUE_INFINITE);
// Step 8. Check for a new best move // Step 8. Check for a new best move
if (value > bestValue) if (value > bestValue)
{ {
bestValue = value; bestValue = value;
if (value > alpha) if (value > alpha)
{ {
bestMove = move; bestMove = move;
if (PvNode) // Update pv even in fail-high case if (PvNode) // Update pv even in fail-high case
update_pv(ss->pv, move, (ss+1)->pv); update_pv(ss->pv, move, (ss+1)->pv);
if (PvNode && value < beta) // Update alpha here! if (PvNode && value < beta) // Update alpha here!
alpha = value; alpha = value;
else else
break; // Fail high break; // Fail high
} }
} }
} }
// Step 9. Check for mate // Step 9. Check for mate