start to write Breakthrough
This commit is contained in:
1 parent
18d6a96b0d
commit
e27482082b
8 files changed
+158
-15
No files matched your search
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user