mov trajectory
This commit is contained in:
1 parent
5da99ed444
commit
d36ef92b3e
3 files changed
+35
-39
No files matched your search
+4
-37
@@ -1,43 +1,10 @@
|
||||
|
||||
mod trajectory;
|
||||
pub use trajectory::*;
|
||||
|
||||
mod movement_mask;
|
||||
pub use movement_mask::mov_mask;
|
||||
|
||||
struct Board {
|
||||
rook: u64,
|
||||
struct Board<const N: usize> {
|
||||
layers: [[u64; 2]; N],
|
||||
}
|
||||
|
||||
impl Board {
|
||||
|
||||
}
|
||||
|
||||
|
||||
pub fn trajectory(mut position: u64, mask: u64, own_position: u64, enemy_position: u64, shift: i8, mut range: Option<u8>) -> u64 {
|
||||
|
||||
let combined_mask = mask & !own_position;
|
||||
|
||||
let mut l: u64 = 0;
|
||||
|
||||
while position != 0 && range != Some(0) {
|
||||
position = shift_i8(position, shift);
|
||||
position = position & combined_mask;
|
||||
|
||||
l = l | position;
|
||||
|
||||
position = position & !enemy_position;
|
||||
|
||||
if let Some(ref mut n) = range {
|
||||
*n -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
l
|
||||
}
|
||||
|
||||
fn shift_i8(value: u64, amount: i8) -> u64{
|
||||
if amount >= 0 {
|
||||
value << amount
|
||||
} else {
|
||||
value >> (-amount)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
pub fn trajectory(mut position: u64, mask: u64, own_position: u64, enemy_position: u64, shift: i8, mut range: Option<u8>) -> u64 {
|
||||
|
||||
let combined_mask = mask & !own_position;
|
||||
|
||||
let mut l: u64 = 0;
|
||||
|
||||
while position != 0 && range != Some(0) {
|
||||
position = shift_i8(position, shift);
|
||||
position = position & combined_mask;
|
||||
|
||||
l = l | position;
|
||||
|
||||
position = position & !enemy_position;
|
||||
|
||||
if let Some(ref mut n) = range {
|
||||
*n -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
l
|
||||
}
|
||||
|
||||
fn shift_i8(value: u64, amount: i8) -> u64{
|
||||
if amount >= 0 {
|
||||
value << amount
|
||||
} else {
|
||||
value >> (-amount)
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -15,8 +15,8 @@ fn main() {
|
||||
let full: u64 = 0xfefefefefefefefe;
|
||||
|
||||
let own: u64 = 0xffff002100000000;
|
||||
// let wr: u64 = 0x000000000004c83b;
|
||||
let wr: u64 = 128;
|
||||
let wr: u64 = 0x000000000004c83b;
|
||||
// let wr: u64 = 128;
|
||||
|
||||
let bish: u64 = 0x0000002100000000;
|
||||
|
||||
|
||||
Reference in new issue
Block a user