[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 square = piece.square();
if self.by_color.bitboard(color).is_set(piece.square()) {
match strategy {
PlacePieceStrategy::Replace => todo!(),
PlacePieceStrategy::PreserveExisting => {
return Err(PlacePieceError::ExisitingPiece)
}
}
if strategy == PlacePieceStrategy::PreserveExisting
&& self.by_color.bitboard(color).is_set(piece.square())
{
return Err(PlacePieceError::ExisitingPiece);
}
self.by_color_and_shape.set_square(square, piece.piece());