aboutsummaryrefslogtreecommitdiff
path: root/azalea/src/pathfinder
diff options
context:
space:
mode:
Diffstat (limited to 'azalea/src/pathfinder')
-rw-r--r--azalea/src/pathfinder/astar.rs7
-rw-r--r--azalea/src/pathfinder/mod.rs3
2 files changed, 9 insertions, 1 deletions
diff --git a/azalea/src/pathfinder/astar.rs b/azalea/src/pathfinder/astar.rs
index ed776bec..7bd08111 100644
--- a/azalea/src/pathfinder/astar.rs
+++ b/azalea/src/pathfinder/astar.rs
@@ -17,6 +17,11 @@ where
{
pub movements: Vec<Movement<P, M>>,
pub is_partial: bool,
+ /// The A* cost for executing the path.
+ ///
+ /// For Azalea's pathfinder, this is generally the estimated amount of time
+ /// that it takes to complete the path, in ticks.
+ pub cost: f32,
}
// used for better results when timing out
@@ -79,6 +84,7 @@ where
return Path {
movements: reconstruct_path(nodes, best_path, successors),
is_partial: false,
+ cost: g_score,
};
}
@@ -168,6 +174,7 @@ where
Path {
movements: reconstruct_path(nodes, best_path, successors),
is_partial: true,
+ cost: best_path_scores[best_path],
}
}
diff --git a/azalea/src/pathfinder/mod.rs b/azalea/src/pathfinder/mod.rs
index 8a6e5ef2..905a90fe 100644
--- a/azalea/src/pathfinder/mod.rs
+++ b/azalea/src/pathfinder/mod.rs
@@ -439,6 +439,7 @@ pub fn calculate_path(ctx: CalculatePathCtx) -> Option<PathFoundEvent> {
let astar::Path {
movements,
is_partial,
+ cost,
} = a_star(
RelBlockPos::get_origin(origin),
|n| ctx.goal.heuristic(n.apply(origin)),
@@ -448,7 +449,7 @@ pub fn calculate_path(ctx: CalculatePathCtx) -> Option<PathFoundEvent> {
ctx.opts.max_timeout,
);
let end_time = Instant::now();
- debug!("partial: {is_partial:?}");
+ debug!("partial: {is_partial:?}, cost: {cost}");
let duration = end_time - start_time;
if is_partial {
if movements.is_empty() {