mirror of
https://github.com/opelly27/Stockfish.git
synced 2026-05-20 09:47:46 +00:00
Add comments to uncommented parts of code
https://github.com/official-stockfish/Stockfish/pull/3250 No functional change
This commit is contained in:
committed by
Joost VandeVondele
parent
be7a03a957
commit
8630d03dd4
@@ -844,6 +844,8 @@ namespace {
|
||||
behind |= shift<Down>(behind);
|
||||
behind |= shift<Down+Down>(behind);
|
||||
|
||||
// Compute space score based on the number of safe squares and number of our pieces
|
||||
// increased with number of total blocked pawns in position.
|
||||
int bonus = popcount(safe) + popcount(behind & safe & ~attackedBy[Them][ALL_PIECES]);
|
||||
int weight = pos.count<ALL_PIECES>(Us) - 3 + std::min(pe->blocked_count(), 9);
|
||||
Score score = make_score(bonus * weight * weight / 16, 0);
|
||||
@@ -905,24 +907,36 @@ namespace {
|
||||
{
|
||||
if (pos.opposite_bishops())
|
||||
{
|
||||
// For pure opposite colored bishops endgames use scale factor
|
||||
// based on the number of passed pawns of the strong side.
|
||||
if ( pos.non_pawn_material(WHITE) == BishopValueMg
|
||||
&& pos.non_pawn_material(BLACK) == BishopValueMg)
|
||||
sf = 18 + 4 * popcount(pe->passed_pawns(strongSide));
|
||||
// For every other opposite colored bishops endgames use scale factor
|
||||
// based on the number of all pieces of the strong side.
|
||||
else
|
||||
sf = 22 + 3 * pos.count<ALL_PIECES>(strongSide);
|
||||
}
|
||||
// For rook endgames with strong side not having overwhelming pawn number advantage
|
||||
// and its pawns being on one flank and weak side protecting its pieces with a king
|
||||
// use lower scale factor.
|
||||
else if ( pos.non_pawn_material(WHITE) == RookValueMg
|
||||
&& pos.non_pawn_material(BLACK) == RookValueMg
|
||||
&& pos.count<PAWN>(strongSide) - pos.count<PAWN>(~strongSide) <= 1
|
||||
&& bool(KingSide & pos.pieces(strongSide, PAWN)) != bool(QueenSide & pos.pieces(strongSide, PAWN))
|
||||
&& (attacks_bb<KING>(pos.square<KING>(~strongSide)) & pos.pieces(~strongSide, PAWN)))
|
||||
sf = 36;
|
||||
// For queen vs no queen endgames use scale factor
|
||||
// based on number of minors of side that doesn't have queen.
|
||||
else if (pos.count<QUEEN>() == 1)
|
||||
sf = 37 + 3 * (pos.count<QUEEN>(WHITE) == 1 ? pos.count<BISHOP>(BLACK) + pos.count<KNIGHT>(BLACK)
|
||||
: pos.count<BISHOP>(WHITE) + pos.count<KNIGHT>(WHITE));
|
||||
// In every other case use scale factor based on
|
||||
// the number of pawns of the strong side reduced if pawns are on a single flank.
|
||||
else
|
||||
sf = std::min(sf, 36 + 7 * pos.count<PAWN>(strongSide)) - 4 * !pawnsOnBothFlanks;
|
||||
|
||||
// Reduce scale factor in case of pawns being on a single flank
|
||||
sf -= 4 * !pawnsOnBothFlanks;
|
||||
}
|
||||
|
||||
@@ -1046,6 +1060,8 @@ Value Eval::evaluate(const Position& pos) {
|
||||
bool largePsq = psq * 16 > (NNUEThreshold1 + pos.non_pawn_material() / 64) * r50;
|
||||
bool classical = largePsq || (psq > PawnValueMg / 4 && !(pos.this_thread()->nodes & 0xB));
|
||||
|
||||
// Use classical evaluation for really low piece endgames.
|
||||
// The most critical case is a bishop + A/H file pawn vs naked king draw.
|
||||
bool strongClassical = pos.non_pawn_material() < 2 * RookValueMg && pos.count<PAWN>() < 2;
|
||||
|
||||
v = classical || strongClassical ? Evaluation<NO_TRACE>(pos).value() : adjusted_NNUE();
|
||||
|
||||
Reference in New Issue
Block a user