[board] Simplify the piece placement strategy logic

Check whether the strategy is PreserveExisting before checking if the piece is
already placed.
This commit is contained in:
Eryn Wells 2024-01-27 13:03:18 -08:00
parent bea6dd67c8
commit e8d7f15a7f

View file

@ -87,13 +87,10 @@ impl PieceBitBoards {
let color = piece.color(); let color = piece.color();
let square = piece.square(); let square = piece.square();
if self.by_color.bitboard(color).is_set(piece.square()) { if strategy == PlacePieceStrategy::PreserveExisting
match strategy { && self.by_color.bitboard(color).is_set(piece.square())
PlacePieceStrategy::Replace => todo!(), {
PlacePieceStrategy::PreserveExisting => { return Err(PlacePieceError::ExisitingPiece);
return Err(PlacePieceError::ExisitingPiece)
}
}
} }
self.by_color_and_shape.set_square(square, piece.piece()); self.by_color_and_shape.set_square(square, piece.piece());