-
Notifications
You must be signed in to change notification settings - Fork 66
Open
Description
remove_move and remove_mask truncate moves in the move generator:
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 len = moves.len();
moves.remove_move("e4e3".parse().unwrap());
assert_eq!(moves.len(), len - 1); //Assertion fails with 0 != 8
}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 len = moves.len();
moves.remove_mask(chess::BitBoard::from_square(chess::Square::E3));
assert_eq!(moves.len(), len - 1); //Assertion fails with 0 != 8
}This is because remove_move and remove_mask fail to uphold the invariant where no non-empty SquareAndBitBoards may come after an empty one. This invariant is mentioned here:
Lines 157 to 160 in ad13857
| // the iterator portion of this struct relies on the invariant that | |
| // the bitboards at the beginning of the moves[] array are the only | |
| // ones used. As a result, we must partition the list such that the | |
| // assumption is true. |
This leads to the iterator methods ending early.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels