From fe5ce201ab5a02bbc9dd155f73d81ab98e931b24 Mon Sep 17 00:00:00 2001 From: Michael Whiteley Date: Wed, 3 Jun 2026 13:28:00 -0600 Subject: [PATCH 1/2] I break stuff. TB promo piece. bench 3634130 --- src/types/moves.rs | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/src/types/moves.rs b/src/types/moves.rs index 5d66d7f5a..1c9bcd3d7 100644 --- a/src/types/moves.rs +++ b/src/types/moves.rs @@ -49,6 +49,10 @@ impl Move { Square::new(((self.0 >> 6) & 0b0011_1111) as u8) } + pub const fn fromto(self) -> u16 { + self.0 & 0x0FFF + } + pub const fn kind(self) -> MoveKind { unsafe { mem::transmute((self.0 >> 12) as u8) } } @@ -112,28 +116,12 @@ impl Move { } #[cfg(feature = "syzygy")] - pub const fn to_tb_move(self) -> crate::bindings::TbMove { - const fn promo_bits(pt: PieceType) -> crate::bindings::TbMove { - match pt { - PieceType::Queen => 1, - PieceType::Rook => 2, - PieceType::Bishop => 3, - PieceType::Knight => 4, - _ => unreachable!(), - } - } + pub fn to_tb_move(self) -> crate::bindings::TbMove { + let promo_pt = if self.is_promotion() { + PieceType::King as u16 - self.promo_piece_type() as u16 + } else { 0 }; - let from = self.from() as u16; - let to = self.to() as u16; - - let base = (from << 6) | to; - - if self.is_promotion() { - let promo = promo_bits(self.promo_piece_type()) & 0x7; - base | (promo << 12) - } else { - base - } + self.fromto() | (promo_pt << 12) } pub fn to_uci(self, board: &Board) -> String { From a15517bcbfb7f11b590a6880ae610548ceb33345 Mon Sep 17 00:00:00 2001 From: Michael Whiteley Date: Wed, 3 Jun 2026 13:34:56 -0600 Subject: [PATCH 2/2] Cargo formatting. bench 3634130 --- src/types/moves.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/types/moves.rs b/src/types/moves.rs index 1c9bcd3d7..b619a36af 100644 --- a/src/types/moves.rs +++ b/src/types/moves.rs @@ -117,9 +117,7 @@ impl Move { #[cfg(feature = "syzygy")] pub fn to_tb_move(self) -> crate::bindings::TbMove { - let promo_pt = if self.is_promotion() { - PieceType::King as u16 - self.promo_piece_type() as u16 - } else { 0 }; + let promo_pt = if self.is_promotion() { PieceType::King as u16 - self.promo_piece_type() as u16 } else { 0 }; self.fromto() | (promo_pt << 12) }