Function cetkaik_yhuap_move_candidates::get_blocker_deltas::naive
source · Expand description
Lists the coordinates [dx_block, dy_block]
that can block an attempt for a piece to move to [dx, dy]
use cetkaik_yhuap_move_candidates::get_blocker_deltas::naive;
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(&naive([6,6]), &vec![[1,1], [2,2], [3,3], [4,4], [5,5]]);
assert_eq_ignoring_order(&naive([-6,6]), &vec![[-1,1], [-2,2], [-3,3], [-4,4], [-5,5]]);
assert_eq_ignoring_order(&naive([-5,0]), &vec![[-1,0], [-2,0], [-3,0], [-4,0]]);
assert_eq_ignoring_order(&naive([0,5]), &vec![[0,1], [0,2], [0,3], [0,4]]);
assert_eq_ignoring_order(&naive([0,0]), &vec![]);
// Knight's move is never used in cetkaik, but this function works for those cases too
assert_eq_ignoring_order(&naive([-6,3]), &vec![[-2,1], [-4,2]]);
assert_eq_ignoring_order(&naive([-9,6]), &vec![[-3,2], [-6,4]]);