Tick-based movement costs (replace arbitrary numbers)#8
Conversation
Every movement provider used made-up costs (forward = 1, diagonal = sqrt2, jump = +0.5, a 3-block drop = +1.5, break = 1 + 3*digTime/1000). They had no shared unit, so A* could not honestly compare "walk around" vs "dig through" vs "drop down". Now every cost is measured in game ticks (20/sec) using Baritone's hardcoded estimates, which already lived (unused) in costs.ts. - travelCost(blocks): sprint (or walk) time per block. - Forward / Diagonal: travelCost(1) / travelCost(sqrt2). - ForwardJump: max(jump arc, walk) - you rise and move at once. - ForwardDropDown / StraightDown: walk-off + real FALL_N_BLOCKS_COST fall time. - StraightUp: ladder speed when climbing, else jump + place. - Parkour (forward + diagonal): jump + sprint time across the gap. - breakCost: real mining time in ticks (ms / 50), not a made-up formula. - movement.ts defaults: liquid / place / jump / dig costs are now tick-based. The goal heuristic was already in ticks (walk cost per block). Kept it at the walk cost (not the cheaper sprint cost) on purpose: A* stays a lightly weighted search - same fast beeline - but returned paths are now <=1.3x optimal (walk / sprint = 4.633 / 3.564) instead of the old ~4.6x (per-move cost was ~1 while the heuristic was ~4.633). Centralized that number as COST_HEURISTIC. Verified: build + ts-standard clean, 31/31 tests pass. A deterministic flat benchmark shows identical visited/generated node counts before and after (no search regression); only path quality improves. Added docs/MovementCosts.md. The hard-exclusion detour test asserted "detour > 21 moves"; with realistic costs A* now finds the optimal detour around the wall using diagonals at the same move count (it swings out to |z| >= 4, 0 nodes inside the zone), so that proxy was wrong. The test now asserts that geometric fact directly.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 73d5642ebd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
In-game test (real server)Ran a real offline-mode vanilla 1.20.4 server (superflat, survival, peaceful) and drove a mineflayer bot with To attribute behavior, I ran the identical harness on this branch and on baseline (
Result: walking, diagonals, jump-up (ascend) and drop-down all plan with realistic tick costs and physically execute to the goal. The bot reaches the goal in 4/5 scenarios. The one failure, Net: this is a planning/cost change, and the in-game behavior matches baseline's success profile exactly while making the costs reflect real traversal time. |
|
That executor bug looks like a different issue and could use a separate PR fix. This current code LGTM. |
d0ef472
into
Minecraft-Pathfinding:2026-rewrite
What
Redesigns every movement provider so its cost is a game-tick time estimate instead of an arbitrary number, completing the Baritone-based cost work whose constants already lived (unused) in
costs.ts.Why
Costs used to be made-up:
forward = 1,diagonal = √2,jump = +0.5, a 3-block drop= +1.5, break= 1 + 3·digTime/1000. They had no shared unit, so A* couldn't honestly compare "walk around" vs "dig through" vs "drop down". Now everything is ticks (20/sec), so those comparisons are real.Changes
travelCost(blocks)helper onMovement: sprint (or walk) time per block.SPRINT/WALK_ONE_BLOCK_COST,JUMP_ONE_BLOCK_COST,FALL_N_BLOCKS_COST,WALK_OFF_BLOCK_COST,LADDER_UP_ONE_COST).breakCost: real mining time in ticks (ms / 50) instead of the old made-up formula.movement.tsdefaults (liquidCost,placeCost,jumpCost,digCost) are now tick-based and documented.COST_HEURISTICconstant replaces the repeated20 / 4.317magic number ingoals.ts.docs/MovementCosts.mdexplaining the whole model.No new block lookups, no
splice,Move.coststays read-only (costs are folded in beforeMove.fromPrevious).Heuristic / optimality
The heuristic was already in ticks at the walk cost per block. Kept it there (not the cheaper sprint cost) on purpose: A* stays a lightly weighted search — the same fast beeline as before — but returned paths are now ≤1.3× optimal (walk/sprint = 4.633/3.564) instead of the old ~4.6× (per-move cost was ~1 while the heuristic was ~4.633). Same speed, much better paths.
Verification
npm run build✅ andnpx ts-standard -y✅ (clean).npm test✅ 31/31.|z| ≥ 4, 0 nodes inside the zone), so the old "must be > 21 moves" proxy was wrong; the test now asserts the geometric detour directly.