diff options
| author | Mike White <botahamec@outlook.com> | 2021-09-18 22:49:34 -0400 |
|---|---|---|
| committer | Mike White <botahamec@outlook.com> | 2021-09-18 22:49:34 -0400 |
| commit | 86273330cd6e09b1fe4b9c6efbfb9c56033e28bd (patch) | |
| tree | 9013aa83df8edf4da89837a0732e13903a7ea898 /model/src/board.rs | |
| parent | f0f18161c6a20db901cfd285491b8677e4c41851 (diff) | |
Created a transposition table and fixed some bugs
Diffstat (limited to 'model/src/board.rs')
| -rw-r--r-- | model/src/board.rs | 8 |
1 files changed, 7 insertions, 1 deletions
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<H: Hasher>(&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()) { |
