From e65b0854174c9c90d5eff850428fd07c6912960c Mon Sep 17 00:00:00 2001 From: eug-vs Date: Mon, 23 Jan 2023 12:48:03 +0300 Subject: feat: basic En Passant implementation --- src/square.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/square.rs') diff --git a/src/square.rs b/src/square.rs index ed2877c..1adca83 100644 --- a/src/square.rs +++ b/src/square.rs @@ -19,6 +19,22 @@ impl Square { pub fn to_bitboard(&self) -> Bitboard { 1u64 << *self as u8 } + /// 0-based rank + pub fn rank(&self) -> u8 { + *self as u8 / 8 + } + /// 0-based file + pub fn file(&self) -> u8 { + *self as u8 % 8 + } + + pub fn nort_one(&self) -> Self { + Self::from(*self as u8 + 8) + } + + pub fn sout_one(&self) -> Self { + Self::from(*self as u8 - 8) + } } -- cgit v1.2.3