mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-22 01:56:58 +08:00
Introduce pawn structure based history
Original idea by Seer chess engine https://github.com/connormcmonigle/seer-nnue, coding done by @Disservin, code refactoring done by @locutus2 to match the style of other histories. This patch introduces pawn structure based history, which assings moves values based on last digits of pawn structure hash and piece type of moved piece and landing square of the move. Idea is that good places for pieces are quite often determined by pawn structure of position. Used in 3 different places - sorting of quiet moves, sorting of quiet check evasions and in history based pruning in search. Passed STC: https://tests.stockfishchess.org/tests/view/65391d08cc309ae83955dbaf LLR: 2.95 (-2.94,2.94) <0.00,2.00> Total: 155488 W: 39408 L: 38913 D: 77167 Ptnml(0-2): 500, 18427, 39408, 18896, 513 Passed LTC: https://tests.stockfishchess.org/tests/view/653a36a2cc309ae83955f181 LLR: 2.94 (-2.94,2.94) <0.50,2.50> Total: 70110 W: 17548 L: 17155 D: 35407 Ptnml(0-2): 33, 7859, 18889, 8230, 44 closes https://github.com/official-stockfish/Stockfish/pull/4849 Bench: 1257882 Co-Authored-By: Disservin <disservin.social@gmail.com> Co-Authored-By: Stefan Geschwentner <locutus2@users.noreply.github.com>
This commit is contained in:
@@ -89,12 +89,14 @@ MovePicker::MovePicker(const Position& p,
|
||||
const ButterflyHistory* mh,
|
||||
const CapturePieceToHistory* cph,
|
||||
const PieceToHistory** ch,
|
||||
const PawnHistory& ph,
|
||||
Move cm,
|
||||
const Move* killers) :
|
||||
pos(p),
|
||||
mainHistory(mh),
|
||||
captureHistory(cph),
|
||||
continuationHistory(ch),
|
||||
pawnHistory(ph),
|
||||
ttMove(ttm),
|
||||
refutations{{killers[0], 0}, {killers[1], 0}, {cm, 0}},
|
||||
depth(d) {
|
||||
@@ -110,11 +112,13 @@ MovePicker::MovePicker(const Position& p,
|
||||
const ButterflyHistory* mh,
|
||||
const CapturePieceToHistory* cph,
|
||||
const PieceToHistory** ch,
|
||||
const PawnHistory& ph,
|
||||
Square rs) :
|
||||
pos(p),
|
||||
mainHistory(mh),
|
||||
captureHistory(cph),
|
||||
continuationHistory(ch),
|
||||
pawnHistory(ph),
|
||||
ttMove(ttm),
|
||||
recaptureSquare(rs),
|
||||
depth(d) {
|
||||
@@ -125,9 +129,11 @@ MovePicker::MovePicker(const Position& p,
|
||||
|
||||
// Constructor for ProbCut: we generate captures with SEE greater
|
||||
// than or equal to the given threshold.
|
||||
MovePicker::MovePicker(const Position& p, Move ttm, Value th, const CapturePieceToHistory* cph) :
|
||||
MovePicker::MovePicker(
|
||||
const Position& p, Move ttm, Value th, const CapturePieceToHistory* cph, const PawnHistory& ph) :
|
||||
pos(p),
|
||||
captureHistory(cph),
|
||||
pawnHistory(ph),
|
||||
ttMove(ttm),
|
||||
threshold(th) {
|
||||
assert(!pos.checkers());
|
||||
@@ -203,6 +209,8 @@ void MovePicker::score() {
|
||||
: pt != PAWN ? bool(to & threatenedByPawn) * 15000
|
||||
: 0)
|
||||
: 0;
|
||||
|
||||
m.value += pawnHistory[pawn_structure(pos)][pc][to];
|
||||
}
|
||||
|
||||
else // Type == EVASIONS
|
||||
@@ -212,7 +220,8 @@ void MovePicker::score() {
|
||||
+ (1 << 28);
|
||||
else
|
||||
m.value = (*mainHistory)[pos.side_to_move()][from_to(m)]
|
||||
+ (*continuationHistory[0])[pos.moved_piece(m)][to_sq(m)];
|
||||
+ (*continuationHistory[0])[pos.moved_piece(m)][to_sq(m)]
|
||||
+ pawnHistory[pawn_structure(pos)][pos.moved_piece(m)][to_sq(m)];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user