diff options
| author | eug-vs <eugene@eug-vs.xyz> | 2023-01-22 18:31:44 +0300 | 
|---|---|---|
| committer | eug-vs <eugene@eug-vs.xyz> | 2023-01-22 18:31:44 +0300 | 
| commit | 393a3e57d0323e4403ad73192cecc1bc6e471435 (patch) | |
| tree | 3f06aca28a0719809d14cecc5a21e80a28f84aa7 /src | |
| parent | f5fd1903c995894bbb8574f1191f4f04ae2f2d57 (diff) | |
| download | chessnost-393a3e57d0323e4403ad73192cecc1bc6e471435.tar.gz | |
refactor: compute pieces by color separately
Diffstat (limited to 'src')
| -rw-r--r-- | src/board.rs | 14 | 
1 files changed, 11 insertions, 3 deletions
| diff --git a/src/board.rs b/src/board.rs index 55086bf..a078fff 100644 --- a/src/board.rs +++ b/src/board.rs @@ -100,13 +100,21 @@ impl Board {          !self.occupancy      } -    fn color_occupancy(&self, color: Color) -> Bitboard { -        let mut occupancy = 0; +    fn pieces_by_color(&self, color: Color) -> [Bitboard; 6] { +        let mut pieces = [0; 6];          for (piece_type, piece) in self.pieces.iter().enumerate() {              if piece_type % 2 == color as usize { -                occupancy |= piece; +                pieces[piece_type / 2] = *piece;              }          } +        pieces +    } + +    fn color_occupancy(&self, color: Color) -> Bitboard { +        let mut occupancy = 0; +        for piece in self.pieces_by_color(color) { +            occupancy |= piece; +        }          occupancy      } | 
