diff options
| author | mat <git@matdoes.dev> | 2026-01-05 08:29:53 +0330 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2026-01-05 08:29:53 +0330 |
| commit | db9a9e53ca18911fb2045b7d6af4ed6df388eaaa (patch) | |
| tree | 730e6dda7e9ed41a0595f8a187b3561eb6e2caa1 /azalea/src/pathfinder/astar.rs | |
| parent | c50a8662afeadfce50f64600efa497b07e9bce86 (diff) | |
| download | azalea-drasl-db9a9e53ca18911fb2045b7d6af4ed6df388eaaa.tar.xz | |
fix panic in a_star and some prep for pathfinder swimming
Diffstat (limited to 'azalea/src/pathfinder/astar.rs')
| -rw-r--r-- | azalea/src/pathfinder/astar.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/azalea/src/pathfinder/astar.rs b/azalea/src/pathfinder/astar.rs index 719036f0..04ffdb80 100644 --- a/azalea/src/pathfinder/astar.rs +++ b/azalea/src/pathfinder/astar.rs @@ -170,12 +170,12 @@ where } } - let best_path = determine_best_path(best_paths, 0); + let best_path_idx = determine_best_path_idx(best_paths, 0); log_perf_info(start_time, num_nodes, num_movements); Path { - movements: reconstruct_path(nodes, best_path, successors), + movements: reconstruct_path(nodes, best_paths[best_path_idx], successors), is_partial: true, - cost: best_path_scores[best_path], + cost: best_path_scores[best_path_idx], } } @@ -194,16 +194,16 @@ fn log_perf_info(start_time: Instant, num_nodes: usize, num_movements: usize) { ); } -fn determine_best_path(best_paths: [usize; 7], start: usize) -> usize { +fn determine_best_path_idx(best_paths: [usize; 7], start: usize) -> usize { // this basically makes sure we don't create a path that's really short - for node in best_paths { + for (i, &node) in best_paths.iter().enumerate() { if node != start { - return node; + return i; } } warn!("No best node found, returning first node"); - best_paths[0] + 0 } fn reconstruct_path<P, M, SuccessorsFn>( |
