[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 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());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue