aboutsummaryrefslogtreecommitdiff
path: root/azalea/benches
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2024-12-25 03:00:48 +0000
committermat <git@matdoes.dev>2024-12-25 03:00:48 +0000
commit0ee9ed50e30222784d094e20302cadc879f2b6db (patch)
treef5d730bb298c83e30f67d748d1c5e69d602c1200 /azalea/benches
parentd67aa07c13c335b135080efc59f82df69aa34a95 (diff)
downloadazalea-drasl-0ee9ed50e30222784d094e20302cadc879f2b6db.tar.xz
optimize pathfinder
Diffstat (limited to 'azalea/benches')
-rw-r--r--azalea/benches/pathfinder.rs13
1 files changed, 8 insertions, 5 deletions
diff --git a/azalea/benches/pathfinder.rs b/azalea/benches/pathfinder.rs
index bd47a3bf..d172b9e4 100644
--- a/azalea/benches/pathfinder.rs
+++ b/azalea/benches/pathfinder.rs
@@ -5,6 +5,7 @@ use azalea::{
astar::{self, a_star, PathfinderTimeout},
goals::{BlockPosGoal, Goal},
mining::MiningCache,
+ rel_block_pos::RelBlockPos,
world::CachedWorld,
},
BlockPos,
@@ -124,21 +125,23 @@ fn run_pathfinder_benchmark(
let (world, start, end) = generate_world(&mut partial_chunks, 4);
+ let origin = start;
+
b.iter(|| {
- let cached_world = CachedWorld::new(Arc::new(RwLock::new(world.clone().into())));
+ let cached_world = CachedWorld::new(Arc::new(RwLock::new(world.clone().into())), origin);
let mining_cache =
MiningCache::new(Some(Menu::Player(azalea_inventory::Player::default())));
let goal = BlockPosGoal(end);
- let successors = |pos: BlockPos| {
+ let successors = |pos: RelBlockPos| {
azalea::pathfinder::call_successors_fn(&cached_world, &mining_cache, successors_fn, pos)
};
let astar::Path { movements, partial } = a_star(
- start,
- |n| goal.heuristic(n),
+ RelBlockPos::get_origin(origin),
+ |n| goal.heuristic(n.apply(origin)),
successors,
- |n| goal.success(n),
+ |n| goal.success(n.apply(origin)),
PathfinderTimeout::Time(Duration::MAX),
);