mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-21 17:46:26 +08:00
Simplification of KPsK function
Also the drawing criteria has been slightly loosened. It now detects a draw if the king is ahead of all the pawns and on the same file or the adjacent file. bench: 7700683
This commit is contained in:
committed by
Marco Costalba
parent
2bf18bfc63
commit
3cddb0c076
@@ -684,25 +684,15 @@ ScaleFactor Endgame<KPsK>::operator()(const Position& pos) const {
|
|||||||
|
|
||||||
Square ksq = pos.king_square(weakSide);
|
Square ksq = pos.king_square(weakSide);
|
||||||
Bitboard pawns = pos.pieces(strongSide, PAWN);
|
Bitboard pawns = pos.pieces(strongSide, PAWN);
|
||||||
|
Square psq = pos.list<PAWN>(strongSide)[0];
|
||||||
|
|
||||||
// Are all pawns on the 'a' file?
|
// If all pawns are ahead of the king, all pawns are on a single
|
||||||
if (!(pawns & ~FileABB))
|
// rook file and the king is within one file of the pawns then draw.
|
||||||
{
|
if ( !(pawns & ~in_front_bb(weakSide, rank_of(ksq)))
|
||||||
// Does the defending king block the pawns?
|
&& !((pawns & ~FileABB) && (pawns & ~FileHBB))
|
||||||
if ( square_distance(ksq, relative_square(strongSide, SQ_A8)) <= 1
|
&& file_distance(ksq, psq) <= 1)
|
||||||
|| ( file_of(ksq) == FILE_A
|
|
||||||
&& !(in_front_bb(strongSide, rank_of(ksq)) & pawns)))
|
|
||||||
return SCALE_FACTOR_DRAW;
|
return SCALE_FACTOR_DRAW;
|
||||||
}
|
|
||||||
// Are all pawns on the 'h' file?
|
|
||||||
else if (!(pawns & ~FileHBB))
|
|
||||||
{
|
|
||||||
// Does the defending king block the pawns?
|
|
||||||
if ( square_distance(ksq, relative_square(strongSide, SQ_H8)) <= 1
|
|
||||||
|| ( file_of(ksq) == FILE_H
|
|
||||||
&& !(in_front_bb(strongSide, rank_of(ksq)) & pawns)))
|
|
||||||
return SCALE_FACTOR_DRAW;
|
|
||||||
}
|
|
||||||
return SCALE_FACTOR_NONE;
|
return SCALE_FACTOR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user