From 86273330cd6e09b1fe4b9c6efbfb9c56033e28bd Mon Sep 17 00:00:00 2001 From: Mike White Date: Sat, 18 Sep 2021 22:49:34 -0400 Subject: Created a transposition table and fixed some bugs --- model/src/board.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'model/src/board.rs') diff --git a/model/src/board.rs b/model/src/board.rs index f95d837..a6eba23 100644 --- a/model/src/board.rs +++ b/model/src/board.rs @@ -51,7 +51,7 @@ impl PartialEq for CheckersBitBoard { impl Hash for CheckersBitBoard { /// Hashes with only the pieces part, to ensure correctness and efficiency fn hash(&self, hasher: &mut H) { - self.pieces.hash(hasher) + self.hash_code().hash(hasher) } } @@ -98,6 +98,11 @@ impl CheckersBitBoard { STARTING_BITBOARD } + #[must_use] + pub const fn hash_code(self) -> u64 { + (((self.color & self.pieces) as u64) << 32) | (self.pieces as u64) + } + /// Gets the bits that represent where pieces are on the board #[must_use] pub const fn pieces_bits(self) -> u32 { @@ -634,6 +639,7 @@ impl CheckersBitBoard { .clear_piece(value.wrapping_sub(7) & 31); const KING_MASK: u32 = 0b00000100000100000100000100000000; + // TODO double jump should only apply to the piece that just moved if (is_king || (((1 << value) & KING_MASK) == 0)) && PossibleMoves::has_jumps(board.flip_turn()) { -- cgit v1.2.3