fix shift
This commit is contained in:
@@ -3,6 +3,7 @@ use super::{
|
|||||||
coords::{CoordPair, CoordPairInner},
|
coords::{CoordPair, CoordPairInner},
|
||||||
CoordAxis,
|
CoordAxis,
|
||||||
};
|
};
|
||||||
|
use num::PrimInt;
|
||||||
use static_assertions::const_assert;
|
use static_assertions::const_assert;
|
||||||
|
|
||||||
#[cfg(not(feature = "bitvec"))]
|
#[cfg(not(feature = "bitvec"))]
|
||||||
@@ -45,7 +46,7 @@ impl BitBoard {
|
|||||||
|
|
||||||
// Directional shifts with edge masking (prevents wrapping)
|
// Directional shifts with edge masking (prevents wrapping)
|
||||||
pub const fn east(&self) -> Self {
|
pub const fn east(&self) -> Self {
|
||||||
let mask = !Self::col_mask(Board::BOARD_SIZE).0; // Mask to block column 7 bits
|
let mask = !Self::col_mask(Board::BOARD_SIZE - 1).0; // Mask to block column 7 bits
|
||||||
Self((self.0 & mask) << 1)
|
Self((self.0 & mask) << 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,7 +101,7 @@ impl BitBoard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn intersects(self, other: Self) -> bool {
|
pub fn intersects(self, other: Self) -> bool {
|
||||||
(self & other).count() > 0
|
(self.0 & other.0) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn union(self, other: Self) -> Self {
|
pub fn union(self, other: Self) -> Self {
|
||||||
|
|||||||
@@ -271,9 +271,8 @@ impl Board {
|
|||||||
/// DO NOT USE THIS ALONE, this should be called as a part of
|
/// DO NOT USE THIS ALONE, this should be called as a part of
|
||||||
/// [`Board::place`] or [`Board::place_and_prop_unchecked`]
|
/// [`Board::place`] or [`Board::place_and_prop_unchecked`]
|
||||||
fn propegate_from_dry(&self, coords: CoordPair, starting_color: Piece) -> BitBoard {
|
fn propegate_from_dry(&self, coords: CoordPair, starting_color: Piece) -> BitBoard {
|
||||||
let opponent_color = starting_color.flip();
|
|
||||||
let player_board = *self.board(starting_color);
|
let player_board = *self.board(starting_color);
|
||||||
let opponent_board = *self.board(opponent_color);
|
let opponent_board = *self.board(starting_color.flip());
|
||||||
|
|
||||||
let mut flip_mask = BitBoard::new();
|
let mut flip_mask = BitBoard::new();
|
||||||
let seed = BitBoard::from_coord(coords);
|
let seed = BitBoard::from_coord(coords);
|
||||||
@@ -300,12 +299,12 @@ impl Board {
|
|||||||
if current.count() == 0 || !current.intersects(opponent_board) {
|
if current.count() == 0 || !current.intersects(opponent_board) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
temp_flips = temp_flips.union(current);
|
temp_flips |= current;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If terminated on a player piece, keep the flips
|
// If terminated on a player piece, keep the flips
|
||||||
if current.intersects(player_board) {
|
if current.intersects(player_board) {
|
||||||
flip_mask = flip_mask.union(temp_flips);
|
flip_mask |= temp_flips;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user