mirror of
https://github.com/sockspls/badfish
synced 2025-07-11 19:49:14 +00:00
Add KBPKP endgame
It is a draw if pawns are on G or B files, weaker pawn is on rank 7 and bishop can't attack the pawn. No functional change (because it is very rare and does not appear in bench)
This commit is contained in:
parent
14c2c1395b
commit
c67fb8ef04
1 changed files with 23 additions and 0 deletions
|
@ -471,6 +471,29 @@ ScaleFactor Endgame<KBPsK>::operator()(const Position& pos) const {
|
||||||
return SCALE_FACTOR_DRAW;
|
return SCALE_FACTOR_DRAW;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// All pawns on same B or G file? Then potential draw
|
||||||
|
if ( (pawnFile == FILE_B || pawnFile == FILE_G)
|
||||||
|
&& !(pos.pieces(PAWN) & ~file_bb(pawnFile))
|
||||||
|
&& pos.non_pawn_material(weakerSide) == 0
|
||||||
|
&& pos.piece_count(weakerSide, PAWN) >= 1)
|
||||||
|
{
|
||||||
|
// Get weaker pawn closest to opponent's queening square
|
||||||
|
Bitboard wkPawns = pos.pieces(weakerSide, PAWN);
|
||||||
|
Square weakerPawnSq = strongerSide == WHITE ? msb(wkPawns) : lsb(wkPawns);
|
||||||
|
|
||||||
|
Square strongerKingSq = pos.king_square(strongerSide);
|
||||||
|
Square weakerKingSq = pos.king_square(weakerSide);
|
||||||
|
Square bishopSq = pos.piece_list(strongerSide, BISHOP)[0];
|
||||||
|
|
||||||
|
// Draw if weaker pawn is on rank 7, bishop can't attack the pawn, and
|
||||||
|
// weaker king can stop opposing opponent's king from penetrating.
|
||||||
|
if ( relative_rank(strongerSide, weakerPawnSq) == RANK_7
|
||||||
|
&& opposite_colors(bishopSq, weakerPawnSq)
|
||||||
|
&& square_distance(weakerPawnSq, weakerKingSq) <= square_distance(weakerPawnSq, strongerKingSq))
|
||||||
|
return SCALE_FACTOR_DRAW;
|
||||||
|
}
|
||||||
|
|
||||||
return SCALE_FACTOR_NONE;
|
return SCALE_FACTOR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue