[board] Implement a PositionBuilder; refactor piece bitboards into a PieceBitBoards struct

This makes Position immutable, even if declared mut. I think this will also make
it easier to build positions going forward.

Moving to a PieceBitBoards struct also required a lot of places that return owned
BitBoards to return refs. This is basically fine except for adding a few more &
here and there.

This was a huge refactoring project. All the move generators and a bunch of
BitBoard stuff needed to be updated.
This commit is contained in:
Eryn Wells 2024-01-19 18:08:41 -08:00
parent 939fac80d7
commit 24cce95a88
17 changed files with 472 additions and 381 deletions

View file

@ -53,7 +53,7 @@ impl BitBoard {
}
pub fn is_set(self, sq: Square) -> bool {
!(self & sq.into()).is_empty()
!(self & &sq.into()).is_empty()
}
pub fn set_square(&mut self, sq: Square) {
@ -180,11 +180,15 @@ macro_rules! assign_op {
}
infix_op!(BitAnd, bitand, BitBoard, BitBoard);
infix_op!(BitAnd, bitand, BitBoard, &BitBoard);
infix_op!(BitAnd, bitand, &BitBoard, &BitBoard);
assign_op!(BitAndAssign, bitand_assign, BitBoard);
assign_op!(BitOrAssign, bitor_assign, BitBoard);
infix_op!(BitOr, bitor, BitBoard, BitBoard);
infix_op!(BitOr, bitor, BitBoard, &BitBoard);
infix_op!(BitOr, bitor, &BitBoard, &BitBoard);
impl Not for BitBoard {
type Output = BitBoard;