2024-04-25 13:28:24 -07:00
|
|
|
// Eryn Wells <eryn@erynwells.me>
|
|
|
|
|
|
|
|
#[macro_export]
|
|
|
|
macro_rules! test_board {
|
|
|
|
($to_move:ident, [ $($color:ident $shape:ident on $square:ident),* $(,)? ], $en_passant:ident) => {
|
|
|
|
{
|
2025-05-03 16:02:56 -07:00
|
|
|
let mut board = $crate::Board::empty();
|
2025-05-08 17:37:51 -07:00
|
|
|
$(let _ = board.place_piece(
|
2025-05-03 16:02:56 -07:00
|
|
|
chessfriend_core::Piece::new(
|
|
|
|
chessfriend_core::Color::$color,
|
|
|
|
chessfriend_core::Shape::$shape
|
|
|
|
),
|
2025-05-08 17:37:51 -07:00
|
|
|
chessfriend_core::Square::$square,
|
|
|
|
$crate::PlacePieceStrategy::default());
|
2025-05-03 16:02:56 -07:00
|
|
|
)*
|
2025-06-02 17:29:52 -07:00
|
|
|
board.set_active_color(chessfriend_core::Color::$to_move);
|
2025-05-03 16:02:56 -07:00
|
|
|
board.en_passant_target = Some(chessfriend_core::Square::$en_passant);
|
2024-04-25 13:28:24 -07:00
|
|
|
|
|
|
|
println!("{}", board.display());
|
|
|
|
|
|
|
|
board
|
|
|
|
}
|
|
|
|
};
|
|
|
|
($to_move:ident, [ $($color:ident $shape:ident on $square:ident),* $(,)? ]) => {
|
|
|
|
{
|
2025-05-03 16:02:56 -07:00
|
|
|
let mut board = $crate::Board::empty();
|
2025-05-08 17:37:51 -07:00
|
|
|
$(let _ = board.place_piece(
|
2025-05-03 16:02:56 -07:00
|
|
|
chessfriend_core::Piece::new(
|
|
|
|
chessfriend_core::Color::$color,
|
|
|
|
chessfriend_core::Shape::$shape
|
|
|
|
),
|
|
|
|
chessfriend_core::Square::$square,
|
|
|
|
$crate::PlacePieceStrategy::default());
|
|
|
|
)*
|
2025-05-08 17:37:51 -07:00
|
|
|
board.active_color = chessfriend_core::Color::$to_move;
|
2024-04-25 13:28:24 -07:00
|
|
|
|
|
|
|
println!("{}", board.display());
|
|
|
|
|
2025-05-03 16:02:56 -07:00
|
|
|
board
|
2024-04-25 13:28:24 -07:00
|
|
|
}
|
|
|
|
};
|
|
|
|
($($color:ident $shape:ident on $square:ident),* $(,)?) => {
|
|
|
|
{
|
2025-05-03 16:02:56 -07:00
|
|
|
let mut board = $crate::Board::empty();
|
2025-05-08 17:37:51 -07:00
|
|
|
$(let _ = board.place_piece(
|
2025-05-03 16:02:56 -07:00
|
|
|
chessfriend_core::Piece::new(
|
|
|
|
chessfriend_core::Color::$color,
|
|
|
|
chessfriend_core::Shape::$shape
|
|
|
|
),
|
|
|
|
chessfriend_core::Square::$square,
|
|
|
|
$crate::PlacePieceStrategy::default());
|
|
|
|
)*
|
2024-04-25 13:28:24 -07:00
|
|
|
|
|
|
|
println!("{}", board.display());
|
|
|
|
|
|
|
|
board
|
|
|
|
}
|
|
|
|
};
|
|
|
|
(empty) => {
|
|
|
|
{
|
|
|
|
let board = Board::empty();
|
|
|
|
println!("{}", board.display());
|
|
|
|
board
|
|
|
|
}
|
|
|
|
};
|
|
|
|
(starting) => {
|
|
|
|
{
|
|
|
|
let board = Board::starting();
|
|
|
|
println!("{}", board.display());
|
|
|
|
board
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|