X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fmovepick.h;h=5077f4e3b729b9aa1315d578e62dacad6a2db4e5;hb=a069a1bbbfb60abddbe3fe5276b06f35f783f41c;hp=65e93dda6fe3c1eb0d0b52ce7d66c1609e47c502;hpb=2d0237db3f0e596fb06e3ffbadba84dcc4e018f6;p=stockfish diff --git a/src/movepick.h b/src/movepick.h index 65e93dda..5077f4e3 100644 --- a/src/movepick.h +++ b/src/movepick.h @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -28,9 +29,16 @@ #include "movegen.h" #include "types.h" +#include "position.h" namespace Stockfish { -class Position; + +constexpr int PAWN_HISTORY_SIZE = 512; // has to be a power of 2 + +static_assert((PAWN_HISTORY_SIZE & (PAWN_HISTORY_SIZE - 1)) == 0, + "PAWN_HISTORY_SIZE has to be a power of 2"); + +inline int pawn_structure(const Position& pos) { return pos.pawn_key() & (PAWN_HISTORY_SIZE - 1); } // StatsEntry stores the stat table value. It is usually a number but could // be a move or even a nested history. We use a class instead of a naked value @@ -48,12 +56,12 @@ class StatsEntry { operator const T&() const { return entry; } void operator<<(int bonus) { - assert(abs(bonus) <= D); // Ensure range is [-D, D] + assert(std::abs(bonus) <= D); // Ensure range is [-D, D] static_assert(D <= std::numeric_limits::max(), "D overflows T"); - entry += (bonus * D - entry * abs(bonus)) / (D * 5 / 4); + entry += bonus - entry * std::abs(bonus) / D; - assert(abs(entry) <= D); + assert(std::abs(entry) <= D); } }; @@ -89,11 +97,10 @@ enum StatsType { Captures }; -// ButterflyHistory records how often quiet moves have been successful or -// unsuccessful during the current search, and is used for reduction and move -// ordering decisions. It uses 2 tables (one for each color) indexed by -// the move's from and to squares, see www.chessprogramming.org/Butterfly_Boards -// (~11 elo) +// ButterflyHistory records how often quiet moves have been successful or unsuccessful +// during the current search, and is used for reduction and move ordering decisions. +// It uses 2 tables (one for each color) indexed by the move's from and to squares, +// see www.chessprogramming.org/Butterfly_Boards (~11 elo) using ButterflyHistory = Stats; // CounterMoveHistory stores counter moves indexed by [piece][to] of the previous @@ -112,6 +119,8 @@ using PieceToHistory = Stats; // (~63 elo) using ContinuationHistory = Stats; +// PawnHistory is addressed by the pawn structure and a move's [piece][to] +using PawnHistory = Stats; // MovePicker class is used to pick one pseudo-legal move at a time from the // current position. The most important method is next_move(), which returns a @@ -135,6 +144,7 @@ class MovePicker { const ButterflyHistory*, const CapturePieceToHistory*, const PieceToHistory**, + const PawnHistory*, Move, const Move*); MovePicker(const Position&, @@ -143,7 +153,7 @@ class MovePicker { const ButterflyHistory*, const CapturePieceToHistory*, const PieceToHistory**, - Square); + const PawnHistory*); MovePicker(const Position&, Move, Value, const CapturePieceToHistory*); Move next_move(bool skipQuiets = false); @@ -159,10 +169,10 @@ class MovePicker { const ButterflyHistory* mainHistory; const CapturePieceToHistory* captureHistory; const PieceToHistory** continuationHistory; + const PawnHistory* pawnHistory; Move ttMove; ExtMove refutations[3], *cur, *endMoves, *endBadCaptures; int stage; - Square recaptureSquare; Value threshold; Depth depth; ExtMove moves[MAX_MOVES];