mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-21 01:27:16 +08:00
Use frontmost_sq() and backmost_sq helpers
Should easier to read than the lsb() / msb() low level functions. No functional change.
This commit is contained in:
@@ -443,11 +443,12 @@ ScaleFactor Endgame<KBPsK>::operator()(const Position& pos) const {
|
||||
// The bishop has the wrong color, and the defending king is on the
|
||||
// file of the pawn(s) or the adjacent file. Find the rank of the
|
||||
// frontmost pawn.
|
||||
Rank rank = relative_rank(strongerSide, lsb(weakerSide, pawns));
|
||||
Square pawnSq = frontmost_sq(strongerSide, pawns);
|
||||
|
||||
// If the defending king has distance 1 to the promotion square or
|
||||
// is placed somewhere in front of the pawn, it's a draw.
|
||||
if ( square_distance(kingSq, queeningSq) <= 1
|
||||
|| relative_rank(strongerSide, kingSq) >= rank)
|
||||
|| relative_rank(weakerSide, kingSq) <= relative_rank(weakerSide, pawnSq))
|
||||
return SCALE_FACTOR_DRAW;
|
||||
}
|
||||
}
|
||||
@@ -459,7 +460,7 @@ ScaleFactor Endgame<KBPsK>::operator()(const Position& pos) const {
|
||||
&& pos.count<PAWN>(weakerSide) >= 1)
|
||||
{
|
||||
// Get weakerSide pawn that is closest to home rank
|
||||
Square weakerPawnSq = lsb(weakerSide, pos.pieces(weakerSide, PAWN));
|
||||
Square weakerPawnSq = backmost_sq(weakerSide, pos.pieces(weakerSide, PAWN));
|
||||
|
||||
Square strongerKingSq = pos.king_square(strongerSide);
|
||||
Square weakerKingSq = pos.king_square(weakerSide);
|
||||
|
||||
Reference in New Issue
Block a user