Removing en passant doesn't work
analog-hors opened this issue · comments
Removing en passant moves doesn't work:
fn main() {
let board = "8/8/5k2/8/3Pp3/8/2K5/8 b - d3 0 1".parse().unwrap();
let mut moves = chess::MoveGen::new_legal(&board);
let en_passant = "e4d3".parse().unwrap();
moves.remove_move(en_passant);
assert!(moves.find(|&mv| mv == en_passant).is_none()); //Assertion fails
}
The reason is because the code for removal makes the assumption that each SquareAndBitBoard
has a unique source square, as it masks out the move and then returns:
Lines 140 to 148 in ad13857
However, this assumption fails to hold when en passant is involved, as new
SquareAndBitBoard
s are created for every en passant move.chess/src/movegen/piece_type.rs
Lines 150 to 194 in ad13857
This leads to
remove_move
returning early and never actually removing the move.