diff options
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) + } } |