#![allow(dead_code, unused_macros, unused_imports)]
use spacewalk::{Cost, FullGrid, Grid, Movement, Sq, Step};
pub fn open(g: &FullGrid<Sq>) -> Movement<impl Fn(Step<Sq>) -> Option<Cost> + use<>> {
Movement::scan(g, |_| Some(10))
}
pub fn diagonal_aware(g: &FullGrid<Sq>) -> Movement<impl Fn(Step<Sq>) -> Option<Cost> + use<>> {
Movement::scan(g, |s| Some(if s.dir.is_diagonal() { 14 } else { 10 }))
}
macro_rules! coord_1d {
($coord:ident, $dir:ident, $step:expr) => {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
struct $dir;
crate::common::coord_1d!($coord, $dir = $dir, $step);
};
($coord:ident, $dir:ty = $unit:expr, $step:expr) => {
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
struct $coord(i32);
impl ::std::ops::Add for $coord {
type Output = Self;
fn add(self, o: Self) -> Self {
$coord(self.0 + o.0)
}
}
impl ::std::ops::Sub for $coord {
type Output = Self;
fn sub(self, o: Self) -> Self {
$coord(self.0 - o.0)
}
}
impl ::spacewalk::Coord for $coord {
type Dir = $dir;
const DIRS: &'static [$dir] = &[$unit];
fn step(self, _: $dir) -> Self {
let step: fn(Self) -> Self = $step;
step(self)
}
}
};
}
pub(crate) use coord_1d;