Skip to content

Commit e373018

Browse files
authored
Scale back draw_by_material (#1036)
Fixes rare cases where a king can be mated. bench 2511393 Elo | 0.13 +- 1.21 (95%) SPRT | 8.0+0.08s Threads=1 Hash=16MB LLR | 3.18 (-2.25, 2.89) [-2.75, 0.25] Games | N: 85740 W: 21929 L: 21898 D: 41913 Penta | [430, 9964, 22047, 10003, 426] https://recklesschess.space/test/14823/ Bench: 2759424
1 parent 35a4ecf commit e373018

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

src/board.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,11 @@ impl Board {
247247
}
248248

249249
// Here on, there are exactly 2 non-king minors
250+
251+
// Here, each side has one minor
250252
if self.colored_pieces2(stm, PieceType::Bishop, PieceType::Knight).popcount() == 1 {
251-
return true;
253+
//If a king is in a corner, don't auto draw.
254+
return (Bitboard::CORNERS & self.pieces(PieceType::King)).is_empty();
252255
}
253256

254257
if self.pieces(PieceType::Knight) != Bitboard(0) {

src/types/bitboard.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ impl Bitboard {
1616
pub const SIXTH_RANK: [Bitboard; 2] = [Self::rank(Rank::R6), Self::rank(Rank::R3)];
1717
pub const THIRD_RANK: [Bitboard; 2] = [Self::rank(Rank::R3), Self::rank(Rank::R6)];
1818
pub const HOME_ROWS: [Bitboard; 2] = [Self::rank(Rank::R1), Self::rank(Rank::R8)];
19+
pub const CORNERS: Self = Self(0x8100000000000081);
1920
pub const LEVER_RANKS: [Bitboard; 2] = [Self(0x0000FFFF00000000), Self(0x00000000FFFF0000)];
2021

2122
/// Creates a bitboard with all bits set in the specified rank.

0 commit comments

Comments
 (0)