aboutsummaryrefslogtreecommitdiff
path: root/src/board/zobrist.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/board/zobrist.rs')
-rw-r--r--src/board/zobrist.rs25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/board/zobrist.rs b/src/board/zobrist.rs
index 5286a73..88a2fb7 100644
--- a/src/board/zobrist.rs
+++ b/src/board/zobrist.rs
@@ -18,12 +18,12 @@ pub trait Zobrist {
/// Compute store zobrist hash of the current position
/// https://www.chessprogramming.org/Zobrist_Hashing
- fn compute_hash(&mut self) -> ();
+ fn compute_hash(&mut self);
- fn zobrist_toggle_piece(&mut self, piece_type: Piece, square: Square) -> ();
- fn zobrist_toggle_castling_right(&mut self, color: Color, side: CastlingSide) -> ();
- fn zobrist_toggle_ep_square(&mut self, ep_square: Square) -> ();
- fn zobrist_toggle_color(&mut self) -> ();
+ fn zobrist_toggle_piece(&mut self, piece_type: Piece, square: Square);
+ fn zobrist_toggle_castling_right(&mut self, color: Color, side: CastlingSide);
+ fn zobrist_toggle_ep_square(&mut self, ep_square: Square);
+ fn zobrist_toggle_color(&mut self);
}
impl Zobrist for Board {
@@ -32,7 +32,7 @@ impl Zobrist for Board {
[(); ZOBRIST_SEED_SIZE].map(|_| rng.gen())
}
- fn compute_hash(&mut self) -> () {
+ fn compute_hash(&mut self) {
self.hash = 0;
for piece_id in 0..self.piece_sets.len() {
@@ -48,9 +48,8 @@ impl Zobrist for Board {
}
}
- match self.ep_target {
- Some(square) => self.zobrist_toggle_ep_square(square),
- None => {},
+ if let Some(square) = self.ep_target {
+ self.zobrist_toggle_ep_square(square);
}
if self.color() == Color::Black {
@@ -58,19 +57,19 @@ impl Zobrist for Board {
}
}
- fn zobrist_toggle_piece(&mut self, piece_type: Piece, square: Square) -> () {
+ fn zobrist_toggle_piece(&mut self, piece_type: Piece, square: Square) {
self.hash ^= self.zobrist_seed[piece_type as usize * TOTAL_SQUARES + square as usize];
}
- fn zobrist_toggle_castling_right(&mut self, color: Color, side: CastlingSide) -> () {
+ fn zobrist_toggle_castling_right(&mut self, color: Color, side: CastlingSide) {
self.hash ^= self.zobrist_seed[(TOTAL_PIECES * TOTAL_SQUARES) + color as usize * 2 + side as usize];
}
- fn zobrist_toggle_ep_square(&mut self, ep_square: Square) -> () {
+ fn zobrist_toggle_ep_square(&mut self, ep_square: Square) {
self.hash ^= self.zobrist_seed[(TOTAL_PIECES * TOTAL_SQUARES + TOTAL_CASTLING_RIGHTS) + ep_square.file() as usize];
}
- fn zobrist_toggle_color(&mut self) -> () {
+ fn zobrist_toggle_color(&mut self) {
self.hash ^= self.zobrist_seed[ZOBRIST_SEED_SIZE - 1];
}
}