mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-06 10:53:50 +08:00
Simplify move ordering bonuses for putting piece en prise and escaping capture
Now there is also a penalty for exposing knights and bishops to capture by a pawn. Passed STC: https://tests.stockfishchess.org/tests/view/68074379878abf56f9a0d5b1 LLR: 2.94 (-2.94,2.94) <-1.75,0.25> Total: 96512 W: 24841 L: 24687 D: 46984 Ptnml(0-2): 294, 11336, 24835, 11504, 287 Passed LTC: https://tests.stockfishchess.org/tests/view/6808954a878abf56f9a0d76d LLR: 2.95 (-2.94,2.94) <-1.75,0.25> Total: 221328 W: 56271 L: 56255 D: 108802 Ptnml(0-2): 131, 24149, 62071, 24199, 114 closes https://github.com/official-stockfish/Stockfish/pull/6023 Bench: 1778227
This commit is contained in:
committed by
Disservin
parent
fda269a299
commit
f0de8dc034
@@ -126,21 +126,20 @@ void MovePicker::score() {
|
||||
|
||||
static_assert(Type == CAPTURES || Type == QUIETS || Type == EVASIONS, "Wrong type");
|
||||
|
||||
[[maybe_unused]] Bitboard threatenedByPawn, threatenedByMinor, threatenedByRook,
|
||||
threatenedPieces;
|
||||
[[maybe_unused]] Bitboard threatenedPieces, threatByLesser[4];
|
||||
if constexpr (Type == QUIETS)
|
||||
{
|
||||
Color us = pos.side_to_move();
|
||||
|
||||
threatenedByPawn = pos.attacks_by<PAWN>(~us);
|
||||
threatenedByMinor =
|
||||
pos.attacks_by<KNIGHT>(~us) | pos.attacks_by<BISHOP>(~us) | threatenedByPawn;
|
||||
threatenedByRook = pos.attacks_by<ROOK>(~us) | threatenedByMinor;
|
||||
threatByLesser[0] = threatByLesser[1] = pos.attacks_by<PAWN>(~us);
|
||||
threatByLesser[2] =
|
||||
pos.attacks_by<KNIGHT>(~us) | pos.attacks_by<BISHOP>(~us) | threatByLesser[0];
|
||||
threatByLesser[3] = pos.attacks_by<ROOK>(~us) | threatByLesser[2];
|
||||
|
||||
// Pieces threatened by pieces of lesser material value
|
||||
threatenedPieces = (pos.pieces(us, QUEEN) & threatenedByRook)
|
||||
| (pos.pieces(us, ROOK) & threatenedByMinor)
|
||||
| (pos.pieces(us, KNIGHT, BISHOP) & threatenedByPawn);
|
||||
threatenedPieces = (pos.pieces(us, QUEEN) & threatByLesser[3])
|
||||
| (pos.pieces(us, ROOK) & threatByLesser[2])
|
||||
| (pos.pieces(us, KNIGHT, BISHOP) & threatByLesser[0]);
|
||||
}
|
||||
|
||||
for (auto& m : *this)
|
||||
@@ -172,17 +171,15 @@ void MovePicker::score() {
|
||||
// bonus for checks
|
||||
m.value += (bool(pos.check_squares(pt) & to) && pos.see_ge(m, -75)) * 16384;
|
||||
|
||||
// bonus for escaping from capture
|
||||
m.value += threatenedPieces & from ? (pt == QUEEN && !(to & threatenedByRook) ? 51700
|
||||
: pt == ROOK && !(to & threatenedByMinor) ? 25600
|
||||
: !(to & threatenedByPawn) ? 14450
|
||||
: 0)
|
||||
: 0;
|
||||
|
||||
// malus for putting piece en prise
|
||||
m.value -= (pt == QUEEN && bool(to & threatenedByRook) ? 49000
|
||||
: pt == ROOK && bool(to & threatenedByMinor) ? 24335
|
||||
: 0);
|
||||
// penalty for moving to a square threatened by a lesser piece
|
||||
// or bonus for escaping an attack by a lesser piece.
|
||||
constexpr int bonus[4] = {144, 144, 256, 517};
|
||||
if (KNIGHT <= pt && pt <= QUEEN)
|
||||
{
|
||||
auto i = pt - 2;
|
||||
int v = (threatByLesser[i] & to ? -95 : 100 * bool(threatByLesser[i] & from));
|
||||
m.value += bonus[i] * v;
|
||||
}
|
||||
|
||||
if (ply < LOW_PLY_HISTORY_SIZE)
|
||||
m.value += 8 * (*lowPlyHistory)[ply][m.from_to()] / (1 + 2 * ply);
|
||||
|
||||
Reference in New Issue
Block a user