mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-27 12:36:15 +08:00
Join common code in the stages of next_move()
Rewrite the MovePicker class using lambda expressions for move filtering. Includes code style changes by @mcostalba. Verified for speed, passed STC: LLR: 2.95 (-2.94,2.94) [-3.00,1.00] Total: 43191 W: 9391 L: 9312 D: 24488 http://tests.stockfishchess.org/tests/view/5a99b9df0ebc590297cc8f04 This rewrite of MovePicker.cpp seems to trigger less random crashes on Ryzen machines than the version in previous master (reported by Bojun Guo). Closes https://github.com/official-stockfish/Stockfish/pull/1454 No functional change.
This commit is contained in:
committed by
Stéphane Nicolet
parent
1940485030
commit
bd59560480
@@ -49,7 +49,7 @@ public:
|
||||
void operator<<(int bonus) {
|
||||
|
||||
assert(abs(bonus) <= D); // Ensure range is [-W * D, W * D]
|
||||
assert(abs(W * D) < std::numeric_limits<T>::max()); // Ensure we don't overflow
|
||||
assert(W * D < std::numeric_limits<T>::max()); // Ensure we don't overflow
|
||||
|
||||
entry += bonus * W - entry * abs(bonus) / D;
|
||||
|
||||
@@ -110,6 +110,8 @@ typedef Stats<PieceToHistory, W32, NOT_USED, PIECE_NB, SQUARE_NB> ContinuationHi
|
||||
/// beta algorithm, MovePicker attempts to return the moves which are most likely
|
||||
/// to get a cut-off first.
|
||||
|
||||
enum PickType { NEXT, BEST_SCORE };
|
||||
|
||||
class MovePicker {
|
||||
public:
|
||||
MovePicker(const MovePicker&) = delete;
|
||||
@@ -120,6 +122,7 @@ public:
|
||||
Move next_move(bool skipQuiets = false);
|
||||
|
||||
private:
|
||||
template<PickType T, typename Pred> Move select_move(Pred);
|
||||
template<GenType> void score();
|
||||
ExtMove* begin() { return cur; }
|
||||
ExtMove* end() { return endMoves; }
|
||||
@@ -131,6 +134,7 @@ private:
|
||||
Move ttMove, refutations[3];
|
||||
ExtMove *cur, *endMoves, *endBadCaptures;
|
||||
int stage;
|
||||
Move move;
|
||||
Square recaptureSquare;
|
||||
Value threshold;
|
||||
Depth depth;
|
||||
|
||||
Reference in New Issue
Block a user