[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:
parent
bea6dd67c8
commit
e8d7f15a7f
1 changed files with 4 additions and 7 deletions
|
@ -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());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue