Skip to main content

nearby_walkable

Function nearby_walkable 

Source
pub fn nearby_walkable(
    pos: (usize, usize),
    radius: usize,
    walkmap: &[bool],
    width: usize,
    height: usize,
    periodic: bool,
) -> Vec<(usize, usize)>
Expand description

Returns all walkable grid cells within Chebyshev radius r of pos.

Excludes pos itself. Supports periodic boundaries.

ยงExample

use rustsim_pathfinding::walkability::nearby_walkable;

let walkmap = vec![true; 25]; // 5x5, all walkable
let neighbors = nearby_walkable((2, 2), 1, &walkmap, 5, 5, false);
assert_eq!(neighbors.len(), 8); // 8 neighbors of center cell