13 releases
0.2.8 | Aug 10, 2019 |
---|---|
0.2.7 | Aug 10, 2019 |
0.2.6 | Jul 30, 2019 |
0.2.1 | Jun 30, 2019 |
0.1.3 | Jun 23, 2019 |
#4 in #coord
44 downloads per month
Used in web_wars_engine
19KB
538 lines
πΊοΈ basic-pathfinding
Pathfinding is a simple package for performing 2D A-star pathfinding in square- and hex-based tile grids.
π΄ Rust Usage
let grid = Grid {
tiles:
vec![
vec![1, 1, 0, 1, 1],
vec![1, 1, 0, 1, 1],
vec![1, 1, 0, 1, 1],
vec![1, 1, 1, 1, 1],
vec![1, 1, 1, 1, 1]
],
walkable_tiles: vec![1],
grid_type: GridType::Cardinal,
..Default::default()
);
let start = Coord::new(1, 2);
let end = Coord::new(3, 2);
let path = find_path(&grid, start, end, None);
path == Some(vec![
Coord { x: 1, y: 2 },
Coord { x: 1, y: 3 },
Coord { x: 2, y: 3 },
Coord { x: 3, y: 3 },
Coord { x: 3, y: 2 },
]);
π οΈ Building
cargo build
π¬ Testing
cargo test
Dependencies
~3β12MB
~133K SLoC