inplement .index() in Color
This commit is contained in:
1 parent
45e1843fba
commit
a61395ca6a
3 files changed
+57
-24
No files matched your search
@@ -4,6 +4,8 @@ pub use trajectory::*;
|
||||
mod movement_mask;
|
||||
pub use movement_mask::mov_mask;
|
||||
|
||||
use super::Color;
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct Board<const N: usize> {
|
||||
layers: [[u64; 2]; N],
|
||||
@@ -29,22 +31,22 @@ impl<const N: usize> Board<N> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_mask(&self, x: usize, y: usize) -> u64 {
|
||||
if y >= N || x >= 2 {
|
||||
pub fn get_mask(&self, x: Color, y: usize) -> u64 {
|
||||
if y >= N || x.index() >= 2 {
|
||||
return 0;
|
||||
}
|
||||
self.layers[y][x]
|
||||
self.layers[y][x.index()]
|
||||
}
|
||||
|
||||
pub fn is_mask_zero(&self, x: usize, y: usize) -> bool {
|
||||
pub fn is_mask_zero(&self, x: Color, y: usize) -> bool {
|
||||
self.get_mask(x, y) == 0
|
||||
}
|
||||
|
||||
pub fn and_mask_is_zero(&self, x: usize, y: usize, mask: u64) -> bool {
|
||||
if y >= N || x >= 2 {
|
||||
pub fn and_mask_is_zero(&self, x: Color, y: usize, mask: u64) -> bool {
|
||||
if y >= N || x.index() >= 2 {
|
||||
return true;
|
||||
}
|
||||
(self.layers[y][x] & mask) == 0
|
||||
(self.layers[y][x.index()] & mask) == 0
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user