[position] Pop captured piece from CapturesList on unmake
This commit is contained in:
parent
c476e93f33
commit
c70cefc848
2 changed files with 10 additions and 1 deletions
|
@ -189,7 +189,12 @@ impl Position {
|
||||||
|
|
||||||
let unmake_result = self.board.unmake_move(&last_move_record);
|
let unmake_result = self.board.unmake_move(&last_move_record);
|
||||||
|
|
||||||
if unmake_result.is_err() {
|
if unmake_result.is_ok() {
|
||||||
|
if let Some(capture) = last_move_record.captured_piece {
|
||||||
|
let popped_piece = self.captures.pop(last_move_record.color);
|
||||||
|
debug_assert_eq!(Some(capture), popped_piece);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
self.moves.push(last_move_record);
|
self.moves.push(last_move_record);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,10 @@ impl CapturesList {
|
||||||
self.0[color as usize].push(piece);
|
self.0[color as usize].push(piece);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn pop(&mut self, color: Color) -> Option<Piece> {
|
||||||
|
self.0[color as usize].pop()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn is_empty(&self) -> bool {
|
pub fn is_empty(&self) -> bool {
|
||||||
self.0.iter().all(Vec::is_empty)
|
self.0.iter().all(Vec::is_empty)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue