mirror of
https://github.com/opelly27/Stockfish.git
synced 2026-05-20 07:27:46 +00:00
Use ValueList to represent searched moves array
This PR replaces a pair of array and size with existing ValueList class. Removes two local variables in search and two parameters of update_all_stats. Passed non-regression STC: LLR: 2.93 (-2.94,2.94) <-1.75,0.25> Total: 227040 W: 58472 L: 58463 D: 110105 Ptnml(0-2): 495, 23572, 65427, 23481, 545 https://tests.stockfishchess.org/tests/view/669299204ff211be9d4e98dc closes https://github.com/official-stockfish/Stockfish/pull/5484 No functional change
This commit is contained in:
committed by
Joost VandeVondele
parent
7395d56832
commit
2b37b151dd
+37
-38
@@ -128,16 +128,14 @@ void update_quiet_histories(
|
|||||||
const Position& pos, Stack* ss, Search::Worker& workerThread, Move move, int bonus);
|
const Position& pos, Stack* ss, Search::Worker& workerThread, Move move, int bonus);
|
||||||
void update_quiet_stats(
|
void update_quiet_stats(
|
||||||
const Position& pos, Stack* ss, Search::Worker& workerThread, Move move, int bonus);
|
const Position& pos, Stack* ss, Search::Worker& workerThread, Move move, int bonus);
|
||||||
void update_all_stats(const Position& pos,
|
void update_all_stats(const Position& pos,
|
||||||
Stack* ss,
|
Stack* ss,
|
||||||
Search::Worker& workerThread,
|
Search::Worker& workerThread,
|
||||||
Move bestMove,
|
Move bestMove,
|
||||||
Square prevSq,
|
Square prevSq,
|
||||||
Move* quietsSearched,
|
ValueList<Move, 32>& quietsSearched,
|
||||||
int quietCount,
|
ValueList<Move, 32>& capturesSearched,
|
||||||
Move* capturesSearched,
|
Depth depth);
|
||||||
int captureCount,
|
|
||||||
Depth depth);
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
@@ -554,7 +552,7 @@ Value Search::Worker::search(
|
|||||||
assert(0 < depth && depth < MAX_PLY);
|
assert(0 < depth && depth < MAX_PLY);
|
||||||
assert(!(PvNode && cutNode));
|
assert(!(PvNode && cutNode));
|
||||||
|
|
||||||
Move pv[MAX_PLY + 1], capturesSearched[32], quietsSearched[32];
|
Move pv[MAX_PLY + 1];
|
||||||
StateInfo st;
|
StateInfo st;
|
||||||
ASSERT_ALIGNED(&st, Eval::NNUE::CacheLineSize);
|
ASSERT_ALIGNED(&st, Eval::NNUE::CacheLineSize);
|
||||||
|
|
||||||
@@ -563,18 +561,20 @@ Value Search::Worker::search(
|
|||||||
Depth extension, newDepth;
|
Depth extension, newDepth;
|
||||||
Value bestValue, value, eval, maxValue, probCutBeta;
|
Value bestValue, value, eval, maxValue, probCutBeta;
|
||||||
bool givesCheck, improving, priorCapture, opponentWorsening;
|
bool givesCheck, improving, priorCapture, opponentWorsening;
|
||||||
bool capture, moveCountPruning, ttCapture;
|
bool capture, ttCapture;
|
||||||
Piece movedPiece;
|
Piece movedPiece;
|
||||||
int moveCount, captureCount, quietCount;
|
|
||||||
|
ValueList<Move, 32> capturesSearched;
|
||||||
|
ValueList<Move, 32> quietsSearched;
|
||||||
|
|
||||||
// Step 1. Initialize node
|
// Step 1. Initialize node
|
||||||
Worker* thisThread = this;
|
Worker* thisThread = this;
|
||||||
ss->inCheck = pos.checkers();
|
ss->inCheck = pos.checkers();
|
||||||
priorCapture = pos.captured_piece();
|
priorCapture = pos.captured_piece();
|
||||||
Color us = pos.side_to_move();
|
Color us = pos.side_to_move();
|
||||||
moveCount = captureCount = quietCount = ss->moveCount = 0;
|
ss->moveCount = 0;
|
||||||
bestValue = -VALUE_INFINITE;
|
bestValue = -VALUE_INFINITE;
|
||||||
maxValue = VALUE_INFINITE;
|
maxValue = VALUE_INFINITE;
|
||||||
|
|
||||||
// Check for the available remaining time
|
// Check for the available remaining time
|
||||||
if (is_mainthread())
|
if (is_mainthread())
|
||||||
@@ -936,8 +936,10 @@ moves_loop: // When in check, search starts here
|
|||||||
MovePicker mp(pos, ttData.move, depth, &thisThread->mainHistory, &thisThread->captureHistory,
|
MovePicker mp(pos, ttData.move, depth, &thisThread->mainHistory, &thisThread->captureHistory,
|
||||||
contHist, &thisThread->pawnHistory, ss->killer);
|
contHist, &thisThread->pawnHistory, ss->killer);
|
||||||
|
|
||||||
value = bestValue;
|
value = bestValue;
|
||||||
moveCountPruning = false;
|
|
||||||
|
int moveCount = 0;
|
||||||
|
bool moveCountPruning = false;
|
||||||
|
|
||||||
// Step 13. Loop through all pseudo-legal moves until no moves remain
|
// Step 13. Loop through all pseudo-legal moves until no moves remain
|
||||||
// or a beta cutoff occurs.
|
// or a beta cutoff occurs.
|
||||||
@@ -1334,9 +1336,9 @@ moves_loop: // When in check, search starts here
|
|||||||
if (move != bestMove && moveCount <= 32)
|
if (move != bestMove && moveCount <= 32)
|
||||||
{
|
{
|
||||||
if (capture)
|
if (capture)
|
||||||
capturesSearched[captureCount++] = move;
|
capturesSearched.push_back(move);
|
||||||
else
|
else
|
||||||
quietsSearched[quietCount++] = move;
|
quietsSearched.push_back(move);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1358,8 +1360,7 @@ moves_loop: // When in check, search starts here
|
|||||||
// If there is a move that produces search value greater than alpha,
|
// If there is a move that produces search value greater than alpha,
|
||||||
// we update the stats of searched moves.
|
// we update the stats of searched moves.
|
||||||
else if (bestMove)
|
else if (bestMove)
|
||||||
update_all_stats(pos, ss, *this, bestMove, prevSq, quietsSearched, quietCount,
|
update_all_stats(pos, ss, *this, bestMove, prevSq, quietsSearched, capturesSearched, depth);
|
||||||
capturesSearched, captureCount, depth);
|
|
||||||
|
|
||||||
// Bonus for prior countermove that caused the fail low
|
// Bonus for prior countermove that caused the fail low
|
||||||
else if (!priorCapture && prevSq != SQ_NONE)
|
else if (!priorCapture && prevSq != SQ_NONE)
|
||||||
@@ -1765,16 +1766,14 @@ void update_pv(Move* pv, Move move, const Move* childPv) {
|
|||||||
|
|
||||||
|
|
||||||
// Updates stats at the end of search() when a bestMove is found
|
// Updates stats at the end of search() when a bestMove is found
|
||||||
void update_all_stats(const Position& pos,
|
void update_all_stats(const Position& pos,
|
||||||
Stack* ss,
|
Stack* ss,
|
||||||
Search::Worker& workerThread,
|
Search::Worker& workerThread,
|
||||||
Move bestMove,
|
Move bestMove,
|
||||||
Square prevSq,
|
Square prevSq,
|
||||||
Move* quietsSearched,
|
ValueList<Move, 32>& quietsSearched,
|
||||||
int quietCount,
|
ValueList<Move, 32>& capturesSearched,
|
||||||
Move* capturesSearched,
|
Depth depth) {
|
||||||
int captureCount,
|
|
||||||
Depth depth) {
|
|
||||||
|
|
||||||
CapturePieceToHistory& captureHistory = workerThread.captureHistory;
|
CapturePieceToHistory& captureHistory = workerThread.captureHistory;
|
||||||
Piece moved_piece = pos.moved_piece(bestMove);
|
Piece moved_piece = pos.moved_piece(bestMove);
|
||||||
@@ -1788,8 +1787,8 @@ void update_all_stats(const Position& pos,
|
|||||||
update_quiet_stats(pos, ss, workerThread, bestMove, quietMoveBonus);
|
update_quiet_stats(pos, ss, workerThread, bestMove, quietMoveBonus);
|
||||||
|
|
||||||
// Decrease stats for all non-best quiet moves
|
// Decrease stats for all non-best quiet moves
|
||||||
for (int i = 0; i < quietCount; ++i)
|
for (Move move : quietsSearched)
|
||||||
update_quiet_histories(pos, ss, workerThread, quietsSearched[i], -quietMoveMalus);
|
update_quiet_histories(pos, ss, workerThread, move, -quietMoveMalus);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1807,11 +1806,11 @@ void update_all_stats(const Position& pos,
|
|||||||
update_continuation_histories(ss - 1, pos.piece_on(prevSq), prevSq, -quietMoveMalus);
|
update_continuation_histories(ss - 1, pos.piece_on(prevSq), prevSq, -quietMoveMalus);
|
||||||
|
|
||||||
// Decrease stats for all non-best capture moves
|
// Decrease stats for all non-best capture moves
|
||||||
for (int i = 0; i < captureCount; ++i)
|
for (Move move : capturesSearched)
|
||||||
{
|
{
|
||||||
moved_piece = pos.moved_piece(capturesSearched[i]);
|
moved_piece = pos.moved_piece(move);
|
||||||
captured = type_of(pos.piece_on(capturesSearched[i].to_sq()));
|
captured = type_of(pos.piece_on(move.to_sq()));
|
||||||
captureHistory[moved_piece][capturesSearched[i].to_sq()][captured] << -quietMoveMalus;
|
captureHistory[moved_piece][move.to_sq()][captured] << -quietMoveMalus;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user