From e9cea33c20e350f211990324025f7be8ac03e9c8 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Thu, 12 Jun 2025 17:41:31 -0700 Subject: [PATCH] [moves] Update ply! to take a color to the castle move This supports castle moves having target and origin squares. --- moves/src/generators/king.rs | 4 ++-- moves/src/moves.rs | 14 ++++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/moves/src/generators/king.rs b/moves/src/generators/king.rs index 864c07d..ed6458b 100644 --- a/moves/src/generators/king.rs +++ b/moves/src/generators/king.rs @@ -258,7 +258,7 @@ mod tests { ply!(E1 - E2), ply!(E1 - F1), ply!(E1 - F2), - ply!(0 - 0), + ply!(White 0-0), ] ); } @@ -279,7 +279,7 @@ mod tests { ply!(E1 - E2), ply!(E1 - F1), ply!(E1 - F2), - ply!(0 - 0 - 0), + ply!(White 0-0-0), ] ); } diff --git a/moves/src/moves.rs b/moves/src/moves.rs index 31226b5..27d8569 100644 --- a/moves/src/moves.rs +++ b/moves/src/moves.rs @@ -46,11 +46,17 @@ macro_rules! ply { $crate::PromotionShape::$promotion, ) }; - (0-0) => { - $crate::Move::castle(chessfriend_core::Wing::KingSide) + ($color:ident 0-0) => { + $crate::Move::castle( + chessfriend_core::Color::$color, + chessfriend_core::Wing::KingSide, + ) }; - (0-0-0) => { - $crate::Move::castle(chessfriend_core::Wing::QueenSide) + ($color:ident 0-0-0) => { + $crate::Move::castle( + chessfriend_core::Color::$color, + chessfriend_core::Wing::QueenSide, + ) }; }