aboutsummaryrefslogtreecommitdiff
path: root/src/square.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/square.rs')
-rw-r--r--src/square.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/square.rs b/src/square.rs
index e518a92..2e47bea 100644
--- a/src/square.rs
+++ b/src/square.rs
@@ -81,6 +81,14 @@ impl Square {
Ok(Self::from_coords(rank as u8, file))
}
+
+ /// Returns the square on the mirrored board,
+ /// e.g E4 becomes E5, G2 becomes G7
+ pub fn mirror(&self) -> Self {
+ let rank = self.rank();
+ let file = self.file();
+ Self::from_coords(7 - rank, file)
+ }
}