[board] Implement position::builders::MoveBuilder
This builder takes a Position and a Move, validates the move, and makes the move in that position. Its build() method returns a new Position with the move made.
This commit is contained in:
parent
7b8ce3b31d
commit
21b5266789
7 changed files with 323 additions and 4 deletions
|
@ -109,6 +109,17 @@ impl Position {
|
|||
true
|
||||
}
|
||||
|
||||
pub(crate) fn rook_for_castle(&self, player: Color, castle: Castle) -> Option<PlacedPiece> {
|
||||
let square = match (player, castle) {
|
||||
(Color::White, Castle::KingSide) => Square::H1,
|
||||
(Color::White, Castle::QueenSide) => Square::A1,
|
||||
(Color::Black, Castle::KingSide) => Square::H8,
|
||||
(Color::Black, Castle::QueenSide) => Square::A8,
|
||||
};
|
||||
|
||||
self.piece_on_square(square)
|
||||
}
|
||||
|
||||
pub fn moves(&self) -> Moves {
|
||||
Moves::new(self, self.color_to_move)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue