diff options
author | eug-vs <eugene@eug-vs.xyz> | 2023-02-23 13:21:57 +0300 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2023-02-23 14:01:19 +0300 |
commit | 43dc24718c442ef45f6cecf5790df0ab84a72cfc (patch) | |
tree | 16f446b1d5a3e0fdf638e0bcab16cf34ec338bd8 /src/board/zobrist.rs | |
parent | f60c573ba71207c18a28413e3940a4e21b07c73f (diff) | |
download | chessnost-43dc24718c442ef45f6cecf5790df0ab84a72cfc.tar.gz |
refactor: apply clippy suggestions
Diffstat (limited to 'src/board/zobrist.rs')
-rw-r--r-- | src/board/zobrist.rs | 25 |
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]; } } |