diff options
| author | eug-vs <eugene@eug-vs.xyz> | 2023-01-23 12:48:03 +0300 | 
|---|---|---|
| committer | eug-vs <eugene@eug-vs.xyz> | 2023-01-23 12:48:03 +0300 | 
| commit | e65b0854174c9c90d5eff850428fd07c6912960c (patch) | |
| tree | d281c0da8368da6b922eac8f12f65f4f4ae4281b /src/square.rs | |
| parent | e6102cda73e854b3050cceb86b9f66bac0b81345 (diff) | |
| download | chessnost-e65b0854174c9c90d5eff850428fd07c6912960c.tar.gz | |
feat: basic En Passant implementation
Diffstat (limited to 'src/square.rs')
| -rw-r--r-- | src/square.rs | 16 | 
1 files changed, 16 insertions, 0 deletions
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) +    }  }  |