[board] Update all the move generator submodules to use MoveBuilder instead of Move
Along the way update "manual" piece creation to use the macros instead.
This commit is contained in:
parent
ca9ff94d2a
commit
2174bcf009
7 changed files with 79 additions and 73 deletions
|
@ -7,7 +7,7 @@ use super::{move_generator_declaration, MoveGeneratorInternal, MoveSet};
|
|||
use crate::{
|
||||
piece::{Color, Piece, PlacedPiece},
|
||||
position::BoardSide,
|
||||
BitBoard, Move, Position,
|
||||
BitBoard, Move, MoveBuilder, Position,
|
||||
};
|
||||
|
||||
move_generator_declaration!(KingMoveGenerator, struct);
|
||||
|
@ -56,7 +56,7 @@ impl<'pos> MoveGeneratorInternal for KingMoveGenerator<'pos> {
|
|||
// TODO: Handle checks. Prevent moving a king to a square attacked by a
|
||||
// piece of the opposite color.
|
||||
|
||||
let map_to_move = |sq| Move::new(piece, square, sq);
|
||||
let map_to_move = |sq| MoveBuilder::new(piece, square, sq).build();
|
||||
|
||||
let king_side_castle = Self::king_side_castle(position, color);
|
||||
let queen_side_castle = Self::queen_side_castle(position, color);
|
||||
|
@ -76,7 +76,7 @@ impl<'pos> MoveGeneratorInternal for KingMoveGenerator<'pos> {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{piece::Piece, Position, Square};
|
||||
use crate::{piece, piece::Piece, Position, Square};
|
||||
use std::collections::HashSet;
|
||||
|
||||
#[test]
|
||||
|
@ -96,14 +96,14 @@ mod tests {
|
|||
);
|
||||
|
||||
let expected_moves = [
|
||||
Move::new(Piece::king(Color::White), Square::E4, Square::D5),
|
||||
Move::new(Piece::king(Color::White), Square::E4, Square::E5),
|
||||
Move::new(Piece::king(Color::White), Square::E4, Square::F5),
|
||||
Move::new(Piece::king(Color::White), Square::E4, Square::F4),
|
||||
Move::new(Piece::king(Color::White), Square::E4, Square::F3),
|
||||
Move::new(Piece::king(Color::White), Square::E4, Square::E3),
|
||||
Move::new(Piece::king(Color::White), Square::E4, Square::D3),
|
||||
Move::new(Piece::king(Color::White), Square::E4, Square::D4),
|
||||
MoveBuilder::new(piece!(White King), Square::E4, Square::D5).build(),
|
||||
MoveBuilder::new(piece!(White King), Square::E4, Square::E5).build(),
|
||||
MoveBuilder::new(piece!(White King), Square::E4, Square::F5).build(),
|
||||
MoveBuilder::new(piece!(White King), Square::E4, Square::F4).build(),
|
||||
MoveBuilder::new(piece!(White King), Square::E4, Square::F3).build(),
|
||||
MoveBuilder::new(piece!(White King), Square::E4, Square::E3).build(),
|
||||
MoveBuilder::new(piece!(White King), Square::E4, Square::D3).build(),
|
||||
MoveBuilder::new(piece!(White King), Square::E4, Square::D4).build(),
|
||||
];
|
||||
|
||||
let mut generated_moves: HashSet<Move> = generator.iter().cloned().collect();
|
||||
|
@ -140,9 +140,9 @@ mod tests {
|
|||
);
|
||||
|
||||
let expected_moves = [
|
||||
Move::new(Piece::king(Color::White), Square::A1, Square::A2),
|
||||
Move::new(Piece::king(Color::White), Square::A1, Square::B1),
|
||||
Move::new(Piece::king(Color::White), Square::A1, Square::B2),
|
||||
MoveBuilder::new(piece!(White King), Square::A1, Square::A2).build(),
|
||||
MoveBuilder::new(piece!(White King), Square::A1, Square::B1).build(),
|
||||
MoveBuilder::new(piece!(White King), Square::A1, Square::B2).build(),
|
||||
];
|
||||
|
||||
let mut generated_moves: HashSet<Move> = generator.iter().cloned().collect();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue