[board] Replace Moves' separate properties with a Vec of Iterators
This makes iteration easier. Move to the next iterator if the current one returns None. No tests for Moves yet though.
This commit is contained in:
parent
c2c0af20fb
commit
878d771d86
3 changed files with 44 additions and 15 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
use super::Pieces;
|
||||
use crate::bitboard::BitBoard;
|
||||
use crate::moves::MoveGenerator;
|
||||
use crate::moves::Moves;
|
||||
use crate::piece::{Color, Piece, PiecePlacementError, PlacedPiece, Shape};
|
||||
use crate::Square;
|
||||
use std::fmt;
|
||||
|
@ -94,8 +94,8 @@ impl Position {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn move_generator(&self) -> MoveGenerator {
|
||||
MoveGenerator::new(self)
|
||||
pub fn move_generator(&self, color: Color) -> Moves {
|
||||
Moves::new(self, color)
|
||||
}
|
||||
|
||||
/// Return a BitBoard representing the set of squares containing a piece.
|
||||
|
@ -103,7 +103,8 @@ impl Position {
|
|||
self.pieces_per_color[Color::White as usize] | self.pieces_per_color[Color::Black as usize]
|
||||
}
|
||||
|
||||
/// Return a BitBoard representing the set of squares containing a piece. This set is the inverse of `occupied_squares`.
|
||||
/// Return a BitBoard representing the set of squares containing a piece.
|
||||
/// This set is the inverse of `occupied_squares`.
|
||||
pub(crate) fn empty_squares(&self) -> BitBoard {
|
||||
!(self.pieces_per_color[Color::White as usize]
|
||||
| self.pieces_per_color[Color::Black as usize])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue