mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 08:43:09 +00:00
Simplify KBPKB endgame with opposite bishops
When we reach a position with only two opposite colored bishops and one pawn on the board, current master would give it a scale factor of 9/64=0.14 in about one position out of 7200, and a scale factor of 0.0 in the 7199 others. The patch gives a scale factor of 0.0 in 100% of the cases. STC: LLR: 2.96 (-2.94,2.94) [-3.00,1.00] Total: 55845 W: 11467 L: 11410 D: 32968 http://tests.stockfishchess.org/tests/view/5abc585f0ebc5902926cf15e LTC: LLR: 2.95 (-2.94,2.94) [-3.00,1.00] Total: 11915 W: 1852 L: 1719 D: 8344 http://tests.stockfishchess.org/tests/view/5abc7f750ebc5902926cf18c We also have exhaustive coverage analysis of this patch effect by Alain Savard, comparing the perfect evaluation given by the Syzygy tablebase with the heuristic play after this patch for the set of all legal positions of the KBPKP endgame with opposite bishops, in the comments thread for this pull request: https://github.com/official-stockfish/Stockfish/pull/1520 Alain's conclusion: > According to this definition and the data, I consider this PR is > identical to master to "solve for draw" and slightly better than > master to solve earlier for "wins". Note: this patch is a side effect of an ongoing effort to improve the evaluation of positions involving a pair of opposite bishops. See the GitHub diff of this LTC test which almost passed at sprt[0..5] for a discussion: http://tests.stockfishchess.org/tests/view/5ab9030b0ebc5902932cbf93 No functional change (at small bench depths)
This commit is contained in:
parent
f2681232e5
commit
d9cac9a414
2 changed files with 3 additions and 25 deletions
|
@ -631,29 +631,8 @@ ScaleFactor Endgame<KBPKB>::operator()(const Position& pos) const {
|
||||||
|
|
||||||
// Case 2: Opposite colored bishops
|
// Case 2: Opposite colored bishops
|
||||||
if (opposite_colors(strongBishopSq, weakBishopSq))
|
if (opposite_colors(strongBishopSq, weakBishopSq))
|
||||||
{
|
return SCALE_FACTOR_DRAW;
|
||||||
// We assume that the position is drawn in the following three situations:
|
|
||||||
//
|
|
||||||
// a. The pawn is on rank 5 or further back.
|
|
||||||
// b. The defending king is somewhere in the pawn's path.
|
|
||||||
// c. The defending bishop attacks some square along the pawn's path,
|
|
||||||
// and is at least three squares away from the pawn.
|
|
||||||
//
|
|
||||||
// These rules are probably not perfect, but in practice they work
|
|
||||||
// reasonably well.
|
|
||||||
|
|
||||||
if (relative_rank(strongSide, pawnSq) <= RANK_5)
|
|
||||||
return SCALE_FACTOR_DRAW;
|
|
||||||
|
|
||||||
Bitboard path = forward_file_bb(strongSide, pawnSq);
|
|
||||||
|
|
||||||
if (path & pos.pieces(weakSide, KING))
|
|
||||||
return SCALE_FACTOR_DRAW;
|
|
||||||
|
|
||||||
if ( (pos.attacks_from<BISHOP>(weakBishopSq) & path)
|
|
||||||
&& distance(weakBishopSq, pawnSq) >= 3)
|
|
||||||
return SCALE_FACTOR_DRAW;
|
|
||||||
}
|
|
||||||
return SCALE_FACTOR_NONE;
|
return SCALE_FACTOR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -800,11 +800,10 @@ namespace {
|
||||||
{
|
{
|
||||||
if (pos.opposite_bishops())
|
if (pos.opposite_bishops())
|
||||||
{
|
{
|
||||||
// Endgame with opposite-colored bishops and no other pieces (ignoring pawns)
|
// Endgame with opposite-colored bishops and no other pieces is almost a draw
|
||||||
// is almost a draw, in case of KBP vs KB, it is even more a draw.
|
|
||||||
if ( pos.non_pawn_material(WHITE) == BishopValueMg
|
if ( pos.non_pawn_material(WHITE) == BishopValueMg
|
||||||
&& pos.non_pawn_material(BLACK) == BishopValueMg)
|
&& pos.non_pawn_material(BLACK) == BishopValueMg)
|
||||||
sf = more_than_one(pos.pieces(PAWN)) ? 31 : 9;
|
sf = 31;
|
||||||
|
|
||||||
// Endgame with opposite-colored bishops, but also other pieces. Still
|
// Endgame with opposite-colored bishops, but also other pieces. Still
|
||||||
// a bit drawish, but not as drawish as with only the two bishops.
|
// a bit drawish, but not as drawish as with only the two bishops.
|
||||||
|
|
Loading…
Add table
Reference in a new issue