This commit is contained in:
Eryn Wells 2025-05-08 17:37:51 -07:00
parent d5cdf273c8
commit 091cc99cb3
42 changed files with 805 additions and 1662 deletions

View file

@ -3,16 +3,7 @@
#[macro_export]
macro_rules! position {
[$($color:ident $shape:ident on $square:ident),* $(,)?] => {
$crate::PositionBuilder::new()
$(.place_piece(
chessfriend_core::PlacedPiece::new(
chessfriend_core::Piece::new(
chessfriend_core::Color::$color,
chessfriend_core::Shape::$shape),
chessfriend_core::Square::$square
)
))*
.build()
$crate::Position::new(chessfriend_board::board!($($color $shape on $square),*))
};
}
@ -21,72 +12,26 @@ macro_rules! position {
macro_rules! test_position {
($to_move:ident, [ $($color:ident $shape:ident on $square:ident),* $(,)? ], $en_passant:ident) => {
{
let pos = $crate::PositionBuilder::new()
$(.place_piece(
chessfriend_core::PlacedPiece::new(
chessfriend_core::Piece::new(
chessfriend_core::Color::$color,
chessfriend_core::Shape::$shape
),
chessfriend_core::Square::$square
))
)*
.to_move(chessfriend_core::Color::$to_move)
.en_passant(Some(chessfriend_moves::EnPassant::from_target_square(chessfriend_core::Square::$en_passant)).unwrap())
.build();
println!("{pos}");
pos
let board = chessfriend_board::test_board!($to_move, [ $($color $shape on $square),*], $en_passant);
$crate::Position::new(board)
}
};
($to_move:ident, [ $($color:ident $shape:ident on $square:ident),* $(,)? ]) => {
{
let pos = $crate::PositionBuilder::new()
$(.place_piece(
chessfriend_core::PlacedPiece::new(
chessfriend_core::Piece::new(
chessfriend_core::Color::$color,
chessfriend_core::Shape::$shape
),
chessfriend_core::Square::$square
))
)*
.to_move(chessfriend_core::Color::$to_move)
.build();
println!("{pos}");
pos
let board = chessfriend_board::test_board!($to_move, [ $($color $shape on $square),* ]);
$crate::Position::new(board)
}
};
($($color:ident $shape:ident on $square:ident),* $(,)?) => {
{
let pos = $crate::PositionBuilder::new()
$(.place_piece(
chessfriend_core::PlacedPiece::new(
chessfriend_core::Piece::new(
chessfriend_core::Color::$color,
chessfriend_core::Shape::$shape
),
chessfriend_core::Square::$square
))
)*
.build();
println!("{pos}");
pos
let board = chessfriend_board::test_board!($($color $shape on $square),*);
$crate::Position::new(board)
}
};
(empty) => {
{
let pos = Position::empty();
println!("{pos}");
pos
}
Position::new(chessfriend_board::test_board!(empty))
};
(starting) => {
{
let pos = Position::starting();
println!("{pos}");
pos
}
Position::new(chessfriend_board::test_board!(starting))
};
}