Skip to content

Commit ebde5ea

Browse files
authored
Correct EP captured (#1021)
Treat EP captures like all other captures setting the capture type, which simplifies undo_move. STC Elo | 0.64 +- 1.62 (95%) SPRT | 8.0+0.08s Threads=1 Hash=16MB LLR | 2.90 (-2.25, 2.89) [-2.75, 0.25] Games | N: 46998 W: 12113 L: 12027 D: 22858 Penta | [154, 5533, 12072, 5553, 187] https://recklesschess.space/test/14767/ Bench: 2851948
1 parent 6c13dcf commit ebde5ea

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

src/board/makemove.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ impl Board {
4545

4646
let captured = self.piece_on(to);
4747
self.state.captured = Some(captured);
48+
self.state.plies_from_null += 1;
4849

4950
if mv.kind() == MoveKind::Capture || pt == PieceType::Pawn {
5051
self.state.halfmove_clock = 0;
5152
} else {
5253
self.state.halfmove_clock += 1;
5354
}
54-
self.state.plies_from_null += 1;
5555

5656
if captured != Piece::None && !mv.is_castling() {
5757
self.remove_piece(piece, from);
@@ -88,6 +88,7 @@ impl Board {
8888
self.update_hash(captured, to ^ 8);
8989

9090
self.state.material -= captured.value();
91+
self.state.captured = Some(captured);
9192
}
9293
MoveKind::Castling => {
9394
let (rook_from, rook_to) = self.get_castling_rook(to);
@@ -174,9 +175,7 @@ impl Board {
174175
self.add_piece(new_mover, from);
175176

176177
if mv.is_capture() {
177-
let captured =
178-
if mv.is_en_passant() { Some(Piece::new(!stm, PieceType::Pawn)) } else { self.state.captured };
179-
self.add_piece(captured.expect("REASON"), mv.capture_sq());
178+
self.add_piece(self.captured_piece().expect("REASON"), mv.capture_sq());
180179
}
181180
}
182181

0 commit comments

Comments
 (0)