Crates.io | stara |
lib.rs | stara |
version | 0.0.3 |
source | src |
created_at | 2024-08-13 20:30:05.059726 |
updated_at | 2024-08-17 09:54:27.177902 |
description | A* Search Algorithm |
homepage | |
repository | https://github.com/piot/stara-rs |
max_upload_size | |
id | 1336467 |
size | 18,710 |
Rust :crab: library implementing the A* pathfinding algorithm.
A*
is used for efficiently finding the shortest path in a grid, mainly used for games.
Add the following to your Cargo.toml
under [dependencies]
to use it in your project:
[dependencies]
stara = "0.0.2"
Here’s an example of how to use the A* pathfinding algorithm with this library:
use stara::prelude::*;
fn main() {
let start = VectorU::new(0, 0);
let goal = VectorU::new(5, 5);
let size = VectorU::new(7, 7);
let mut grid = Grid::new(size, 1);
// Setting an obstacle
grid.set_cost(VectorU::new(3, 3), IMPASSABLE);
let maybe_path = AStar::search(start, goal, &grid);
if let Some(path) = maybe_path {
println!("Path found: {:?}", path);
} else {
println!("No path found.");
}
}
This project is licensed under the MIT License. See the LICENSE file for more details.