Files
pepa-pi-bot/runtime/movement-profiles.js
mayatnikovandClaude Opus 4.7 0aae5e2e68 fix(runtime): wander/explore.far probe-then-go (bot actually moves)
Ground-truth finding (diag.physics):
  forward N:0.03 E:3.38 S:0 W:3.26  → forward WORKS in unobstructed dirs
  jump ΔY=1.25                       → jump WORKS (vanilla height)
  dig untested (no soft block within 6 of spawn)

So the bot CAN move and jump — the previous "stands still" symptom was
our wander/explore code picking blocked random angles and trusting a
pathfinder that times out on this server's terrain. Each retry just
picked another random direction, often the same blocked one.

- runtime/actions.js wander: probe 4 cardinal yaws for 800ms each,
  measure actual Δ, commit to the best one for the remaining budget.
  Falls back to "wedged-jump" (forward+jump 2.5s) only when ALL four
  cardinals are <0.5 blocks.
- runtime/skills/explore-far.js: same probe-then-go shape, scaled to a
  ~48-block long walk in the best direction. Replaces the static
  NE/SE/SW/NW quadrant rotation that ignored what was actually
  walkable.
- runtime/movement-profiles.js: canDig back to true on gather/travel/
  flee. The earlier "everything false" defensive default was based on
  a wrong hypothesis (silent dig failure) — diag.physics + server-side
  inspection (no anti-cheat plugin, spawn-protection=0) showed dig is
  fine.
- runtime/compat.test.js: assertions follow profile defaults.
- runtime/skills/diagnose-physics.js: forward probe now tries 4
  cardinals and returns trials + bestDir + bestDist so it can be used
  to debug "wedged" reports later.

Verified live: bot now actually walks 47 blocks north after
probe.cardinal showed N:2.4 free. First end-to-end real movement on
play.xmatic.team since this session started.

npm test 124/124.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 12:05:14 +03:00

57 lines
2.2 KiB
JavaScript

// Movement safety profiles. mineflayer-pathfinder's Movements object
// is shared per-bot — if one skill sets canDig=false and another
// inherits that, you get the live regression from earlier: flee with
// canDig=false leaves the bot stuck in a tree canopy forever.
//
// Each named profile is a flat descriptor (pure JS object) that the
// caller can either inspect directly (tests do this) or apply to a
// pathfinder Movements via applyProfile(profile, bot).
import pathfinderPkg from "mineflayer-pathfinder";
const { Movements } = pathfinderPkg;
export const PROFILES = Object.freeze({
GATHER: "gather",
TRAVEL: "travel",
FLEE: "flee",
BUILD: "build",
RETURN_TO_BASE: "return_to_base",
});
// Pure descriptors — safe to import without a live bot.
//
// 2026-05-26 update: ground-truth probe (diag.physics) on
// play.xmatic.team confirmed forward + jump work in normal directions
// (forward Δ≈3.4 blocks/1.2s in an unobstructed cardinal, jump ΔY=1.25
// = vanilla height). The 1.21.4 pin + AuthMe login flow are doing
// their job. canDig is back to true on gather/travel/flee — pathfinder
// needs to be able to break leaves/dirt to actually move around.
export const PROFILE_DEFAULTS = Object.freeze({
[PROFILES.GATHER]: { canDig: true, canPlace: false, allow1by1towers: false },
[PROFILES.TRAVEL]: { canDig: true, canPlace: false, allow1by1towers: false },
[PROFILES.FLEE]: { canDig: true, canPlace: false, allow1by1towers: false, maxDropDown: 8 },
[PROFILES.BUILD]: { canDig: false, canPlace: true, allow1by1towers: true },
[PROFILES.RETURN_TO_BASE]: { canDig: false, canPlace: false, allow1by1towers: false },
});
export function describeProfile(profile) {
const desc = PROFILE_DEFAULTS[profile];
if (!desc) throw new Error(`unknown movement profile: ${profile}`);
return desc;
}
// Build a fresh Movements applying the descriptor; does NOT call setMovements.
export function buildProfile(profile, bot) {
const desc = describeProfile(profile);
const m = new Movements(bot);
for (const [k, v] of Object.entries(desc)) m[k] = v;
return m;
}
// Convenience: build + apply.
export function applyProfile(profile, bot) {
const m = buildProfile(profile, bot);
bot.pathfinder.setMovements(m);
return m;
}