diff options
| author | mat <git@matdoes.dev> | 2026-01-14 21:01:40 -1000 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2026-01-15 12:10:10 -0530 |
| commit | 9c8cf7adea6da1c76d96f447b71345f63146be10 (patch) | |
| tree | daf473c8064fa49778a227d7d54ca365f85e1208 /azalea | |
| parent | 14b9166afb5d6563774bf7a4336d4e6807e01ebb (diff) | |
| download | azalea-drasl-9c8cf7adea6da1c76d96f447b71345f63146be10.tar.xz | |
more optimal pathfinder ascend_move
Diffstat (limited to 'azalea')
| -rw-r--r-- | azalea/src/pathfinder/costs.rs | 4 | ||||
| -rw-r--r-- | azalea/src/pathfinder/moves/basic.rs | 16 |
2 files changed, 10 insertions, 10 deletions
diff --git a/azalea/src/pathfinder/costs.rs b/azalea/src/pathfinder/costs.rs index 713ac364..d5141294 100644 --- a/azalea/src/pathfinder/costs.rs +++ b/azalea/src/pathfinder/costs.rs @@ -13,7 +13,8 @@ pub const WALK_ONE_IN_WATER_COST: f32 = 20. / 1.960; // 10.204 // explanation here: // https://github.com/cabaletta/baritone/blob/f147519a5c291015d4f18c94558a3f1bdcdb9588/src/api/java/baritone/api/Settings.java#L405 -// it's basically just the heuristic multiplier +// it's basically a multiplier used by some heuristics to convert x and z +// distance to ticks pub const COST_HEURISTIC: f32 = 3.563; // this one is also from baritone, it's helpful as a tiebreaker to avoid @@ -64,7 +65,6 @@ fn velocity(ticks: usize) -> f32 { fn distance_to_ticks(distance: f32) -> f32 { if distance == 0. { - // Avoid 0/0 NaN return 0.; } let mut tick_count = 0; diff --git a/azalea/src/pathfinder/moves/basic.rs b/azalea/src/pathfinder/moves/basic.rs index b0fea827..2814641c 100644 --- a/azalea/src/pathfinder/moves/basic.rs +++ b/azalea/src/pathfinder/moves/basic.rs @@ -87,6 +87,13 @@ fn ascend_move(ctx: &mut PathfinderCtx, pos: RelBlockPos) { stair_facing = Some(found_stair_facing); } + let break_cost_1 = ctx + .world + .cost_for_breaking_block(pos.up(2), ctx.mining_cache); + if break_cost_1 == f32::INFINITY { + return; + } + for dir in CardinalDirection::iter() { if let Some(stair_facing) = stair_facing { let expected_stair_facing = cardinal_direction_to_facing_property(dir); @@ -97,20 +104,13 @@ fn ascend_move(ctx: &mut PathfinderCtx, pos: RelBlockPos) { let offset = RelBlockPos::new(dir.x(), 1, dir.z()); - let break_cost_1 = ctx - .world - .cost_for_breaking_block(pos.up(2), ctx.mining_cache); - if break_cost_1 == f32::INFINITY { - continue; - } let break_cost_2 = ctx.world.cost_for_standing(pos + offset, ctx.mining_cache); if break_cost_2 == f32::INFINITY { continue; } - let cost = SPRINT_ONE_BLOCK_COST + let cost = f32::max(WALK_ONE_BLOCK_COST, *JUMP_ONE_BLOCK_COST) + JUMP_PENALTY - + *JUMP_ONE_BLOCK_COST + break_cost_1 + break_cost_2; |
