work fundamental funktion: trajectory
This commit is contained in:
1 parent
9ab067ae7d
commit
90c8c9882b
3 files changed
+57
-4
No files matched your search
@@ -0,0 +1,40 @@
|
|||||||
|
|
||||||
|
|
||||||
|
struct Board {
|
||||||
|
rook: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
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,2 @@
|
|||||||
|
|
||||||
|
|
||||||
+15
-4
@@ -1,3 +1,6 @@
|
|||||||
|
mod board;
|
||||||
|
use board::*;
|
||||||
|
|
||||||
mod render_bitmask;
|
mod render_bitmask;
|
||||||
use render_bitmask::*;
|
use render_bitmask::*;
|
||||||
|
|
||||||
@@ -8,15 +11,23 @@ fn main() {
|
|||||||
|
|
||||||
let kp: u64 = (1 << 38) | (1 << 45) | (1 << 43) | (1 << 34) | (1 << 18) | (1 << 11) | (1 << 13) | (1 << 22);
|
let kp: u64 = (1 << 38) | (1 << 45) | (1 << 43) | (1 << 34) | (1 << 18) | (1 << 11) | (1 << 13) | (1 << 22);
|
||||||
|
|
||||||
// render_bitmask::render_u64(a);
|
|
||||||
|
let full: u64 = 0xfefefefefefefefe;
|
||||||
|
|
||||||
|
let own: u64 = 0xffff002100000000;
|
||||||
|
let wr: u64 = 0x000000000004c83b;
|
||||||
|
|
||||||
|
let bish: u64 = 0x0000002100000000;
|
||||||
|
|
||||||
|
let ans: u64 = trajectory(bish, full, own, wr, -7, None);
|
||||||
|
|
||||||
|
|
||||||
// render_bitmask::render_board(render_bitmask::BoardColor::Checkerboard(' ', '"'));
|
|
||||||
|
|
||||||
render_board(BoardColor::Solid(':'), vec![(k, 'k'), (kp, 'o')]);
|
|
||||||
|
render_board(BoardColor::Solid(':'), vec![(ans & wr,'t'), (ans, 'm'), (bish, 'a')]);
|
||||||
|
|
||||||
print!("\n");
|
print!("\n");
|
||||||
|
|
||||||
render_board(BoardColor::Checkerboard(' ', ':'), vec![(k, 'k'), (kp, 'o')]);
|
render_board(BoardColor::Solid(':'), vec![(wr, 'k'), (own, 'w')]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference in new issue
Block a user