mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-06 10:53:50 +08:00
Minor code improvements
- Remove / add empty lines - fix the `ttcapture` comment - remove the `bonus` variable for `ttMoveHistory` - remove unnecessary parentheses / brackets - refactor the movepick good quiet stage - rename `endMoves` to `endCur`, as the previous name suggests that it points to the end of all generated moves, which it does not. closes https://github.com/official-stockfish/Stockfish/pull/6089 No functional change. Co-Authored-By: xu-shawn <50402888+xu-shawn@users.noreply.github.com>
This commit is contained in:
committed by
Joost VandeVondele
parent
f58d923fe0
commit
b1b5893a8e
@@ -173,7 +173,7 @@ void MovePicker::score() {
|
||||
if (KNIGHT <= pt && pt <= QUEEN)
|
||||
{
|
||||
static constexpr int bonus[QUEEN + 1] = {0, 0, 144, 144, 256, 517};
|
||||
int v = (threatByLesser[pt] & to ? -95 : 100 * bool(threatByLesser[pt] & from));
|
||||
int v = threatByLesser[pt] & to ? -95 : 100 * bool(threatByLesser[pt] & from);
|
||||
m.value += bonus[pt] * v;
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ void MovePicker::score() {
|
||||
template<typename Pred>
|
||||
Move MovePicker::select(Pred filter) {
|
||||
|
||||
for (; cur < endMoves; ++cur)
|
||||
for (; cur < endCur; ++cur)
|
||||
if (*cur != ttMove && filter())
|
||||
return *cur++;
|
||||
|
||||
@@ -227,10 +227,10 @@ top:
|
||||
case PROBCUT_INIT :
|
||||
case QCAPTURE_INIT :
|
||||
cur = endBadCaptures = moves;
|
||||
endMoves = generate<CAPTURES>(pos, cur);
|
||||
endCur = generate<CAPTURES>(pos, cur);
|
||||
|
||||
score<CAPTURES>();
|
||||
partial_insertion_sort(cur, endMoves, std::numeric_limits<int>::min());
|
||||
partial_insertion_sort(cur, endCur, std::numeric_limits<int>::min());
|
||||
++stage;
|
||||
goto top;
|
||||
|
||||
@@ -250,10 +250,10 @@ top:
|
||||
if (!skipQuiets)
|
||||
{
|
||||
cur = endBadQuiets = endBadCaptures;
|
||||
endMoves = generate<QUIETS>(pos, cur);
|
||||
endCur = generate<QUIETS>(pos, cur);
|
||||
|
||||
score<QUIETS>();
|
||||
partial_insertion_sort(cur, endMoves, -3560 * depth);
|
||||
partial_insertion_sort(cur, endCur, -3560 * depth);
|
||||
}
|
||||
|
||||
++stage;
|
||||
@@ -261,13 +261,16 @@ top:
|
||||
|
||||
case GOOD_QUIET :
|
||||
if (!skipQuiets && select([&]() {
|
||||
return cur->value > -14000 ? true : (*endBadQuiets++ = *cur, false);
|
||||
if (cur->value > -14000)
|
||||
return true;
|
||||
*endBadQuiets++ = *cur;
|
||||
return false;
|
||||
}))
|
||||
return *(cur - 1);
|
||||
|
||||
// Prepare the pointers to loop over the bad captures
|
||||
cur = moves;
|
||||
endMoves = endBadCaptures;
|
||||
endCur = endBadCaptures;
|
||||
|
||||
++stage;
|
||||
[[fallthrough]];
|
||||
@@ -278,7 +281,7 @@ top:
|
||||
|
||||
// Prepare the pointers to loop over the bad quiets
|
||||
cur = endBadCaptures;
|
||||
endMoves = endBadQuiets;
|
||||
endCur = endBadQuiets;
|
||||
|
||||
++stage;
|
||||
[[fallthrough]];
|
||||
@@ -291,10 +294,10 @@ top:
|
||||
|
||||
case EVASION_INIT :
|
||||
cur = moves;
|
||||
endMoves = generate<EVASIONS>(pos, cur);
|
||||
endCur = generate<EVASIONS>(pos, cur);
|
||||
|
||||
score<EVASIONS>();
|
||||
partial_insertion_sort(cur, endMoves, std::numeric_limits<int>::min());
|
||||
partial_insertion_sort(cur, endCur, std::numeric_limits<int>::min());
|
||||
++stage;
|
||||
[[fallthrough]];
|
||||
|
||||
@@ -317,7 +320,7 @@ bool MovePicker::can_move_king_or_pawn() {
|
||||
// SEE negative captures shouldn't be returned in GOOD_CAPTURE stage
|
||||
assert(stage > GOOD_CAPTURE && stage != EVASION_INIT);
|
||||
|
||||
for (ExtMove* m = moves; m < endMoves; ++m)
|
||||
for (ExtMove* m = moves; m < endCur; ++m)
|
||||
{
|
||||
PieceType movedPieceType = type_of(pos.moved_piece(*m));
|
||||
if ((movedPieceType == PAWN || movedPieceType == KING) && pos.legal(*m))
|
||||
|
||||
@@ -58,7 +58,7 @@ class MovePicker {
|
||||
template<GenType>
|
||||
void score();
|
||||
ExtMove* begin() { return cur; }
|
||||
ExtMove* end() { return endMoves; }
|
||||
ExtMove* end() { return endCur; }
|
||||
|
||||
const Position& pos;
|
||||
const ButterflyHistory* mainHistory;
|
||||
@@ -67,7 +67,7 @@ class MovePicker {
|
||||
const PieceToHistory** continuationHistory;
|
||||
const PawnHistory* pawnHistory;
|
||||
Move ttMove;
|
||||
ExtMove * cur, *endMoves, *endBadCaptures, *endBadQuiets;
|
||||
ExtMove * cur, *endCur, *endBadCaptures, *endBadQuiets;
|
||||
int stage;
|
||||
int threshold;
|
||||
Depth depth;
|
||||
|
||||
@@ -680,8 +680,6 @@ Value Search::Worker::search(
|
||||
&& (ttData.bound & (ttData.value >= beta ? BOUND_LOWER : BOUND_UPPER))
|
||||
&& (cutNode == (ttData.value >= beta) || depth > 5))
|
||||
{
|
||||
|
||||
|
||||
// If ttMove is quiet, update move sorting heuristics on TT hit
|
||||
if (ttData.move && ttData.value >= beta)
|
||||
{
|
||||
@@ -712,17 +710,17 @@ Value Search::Worker::search(
|
||||
|
||||
if (!is_valid(ttDataNext.value))
|
||||
return ttData.value;
|
||||
|
||||
if (ttData.value >= beta && -ttDataNext.value >= beta)
|
||||
return ttData.value;
|
||||
|
||||
if (ttData.value <= alpha && -ttDataNext.value <= alpha)
|
||||
return ttData.value;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ttData.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Step 5. Tablebases probe
|
||||
if (!rootNode && !excludedMove && tbConfig.cardinality)
|
||||
@@ -1215,7 +1213,7 @@ moves_loop: // When in check, search starts here
|
||||
if (cutNode)
|
||||
r += 2864 + 966 * !ttData.move;
|
||||
|
||||
// Increase reduction if ttMove is a capture but the current move is not a capture
|
||||
// Increase reduction if ttMove is a capture
|
||||
if (ttCapture)
|
||||
r += 1210 + (depth < 8) * 963;
|
||||
|
||||
@@ -1253,7 +1251,7 @@ moves_loop: // When in check, search starts here
|
||||
// std::clamp has been replaced by a more robust implementation.
|
||||
Depth d = std::max(1, std::min(newDepth - r / 1024,
|
||||
newDepth + !allNode + (PvNode && !bestMove)))
|
||||
+ ((ss - 1)->isPvNode);
|
||||
+ (ss - 1)->isPvNode;
|
||||
|
||||
ss->reduction = newDepth - d;
|
||||
value = -search<NonPV>(pos, ss + 1, -(alpha + 1), -alpha, d, true);
|
||||
@@ -1440,10 +1438,7 @@ moves_loop: // When in check, search starts here
|
||||
update_all_stats(pos, ss, *this, bestMove, prevSq, quietsSearched, capturesSearched, depth,
|
||||
ttData.move, moveCount);
|
||||
if (!PvNode)
|
||||
{
|
||||
int bonus = bestMove == ttData.move ? 800 : -879;
|
||||
ttMoveHistory << bonus;
|
||||
}
|
||||
ttMoveHistory << (bestMove == ttData.move ? 800 : -879);
|
||||
}
|
||||
|
||||
// Bonus for prior quiet countermove that caused the fail low
|
||||
|
||||
Reference in New Issue
Block a user