pub fn ultrafast(delta: [i32; 2]) -> impl Iterator<Item = [i32; 2]>
Expand description

Lists the coordinates [dx_block, dy_block] that can block an attempt for a piece to move to [dx, dy] It is assumed that

  • the direction is either horizontal, vertical, or 45 degrees diagonal
  • the input vector is not zero
use cetkaik_yhuap_move_candidates::get_blocker_deltas::ultrafast;
use std::collections::HashSet;

fn assert_eq_ignoring_order<T>(a: &[T], b: &[T])
where
    T: Eq + core::hash::Hash + std::fmt::Debug,
{
    let a: HashSet<_> = a.iter().collect();
    let b: HashSet<_> = b.iter().collect();

    assert_eq!(a, b);
}
assert_eq_ignoring_order(&ultrafast([6,6]).collect::<Vec<_>>(), &vec![[1,1], [2,2], [3,3], [4,4], [5,5]]);
assert_eq_ignoring_order(&ultrafast([-6,6]).collect::<Vec<_>>(), &vec![[-1,1], [-2,2], [-3,3], [-4,4], [-5,5]]);
assert_eq_ignoring_order(&ultrafast([-5,0]).collect::<Vec<_>>(), &vec![[-1,0], [-2,0], [-3,0], [-4,0]]);
assert_eq_ignoring_order(&ultrafast([0,5]).collect::<Vec<_>>(), &vec![[0,1], [0,2], [0,3], [0,4]]);