fix(runtime): escape-pit fallback for wedged bot
When probe-cardinal shows all 4 directions blocked (the bot is in a 1×1 pit, surrounded by leaves, or in a corridor corner), don't just hold forward+jump — actually dig the block above the bot's head, jump into the new gap, repeat up to 3 times. Both wander and explore.far now call escapePit() in this branch. Observed live: bot fell into a pit at (623,71,106) after first explore.far and looped wedged-jump→still-wedged→wedged-jump for 60s before this fix. With escape-pit, the bot now actually breaks out. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -73,18 +73,11 @@ export const skill = Object.freeze({
|
||||
info("action", `explore.far: cardinal probe trials=${trials.map((t) => `${t.name}:${t.dist.toFixed(1)}`).join(" ")} best=${best.name}`);
|
||||
|
||||
if (best.dist < 0.5) {
|
||||
// All cardinals blocked. Same wedged-jump as wander.
|
||||
info("action", "explore.far: wedged — jump fallback");
|
||||
try { await bot.look(best.yaw ?? 0, 0, true); } catch {}
|
||||
bot.setControlState("forward", true);
|
||||
bot.setControlState("jump", true);
|
||||
try {
|
||||
await new Promise((r) => setTimeout(r, 3_000));
|
||||
} finally {
|
||||
bot.setControlState("forward", false);
|
||||
bot.setControlState("jump", false);
|
||||
}
|
||||
return { ok: true, code: "done", detail: { mode: "wedged-jump", trials }, worldDelta: { movedTo: null } };
|
||||
// All cardinals blocked → escape pit: dig the block above the
|
||||
// bot's head (if any), jump into the gap, repeat. Then break.
|
||||
info("action", "explore.far: wedged — escape-pit (dig up + jump)");
|
||||
await escapePit(bot, 3);
|
||||
return { ok: true, code: "done", detail: { mode: "escape-pit", trials }, worldDelta: null };
|
||||
}
|
||||
|
||||
const here = bot.entity.position.clone();
|
||||
@@ -131,6 +124,32 @@ const CARDINAL_YAWS = [
|
||||
{ name: "W", yaw: Math.PI / 2 },
|
||||
];
|
||||
|
||||
async function escapePit(bot, maxSteps = 3) {
|
||||
for (let i = 0; i < maxSteps; i++) {
|
||||
const head = bot.entity.position.offset(0, 1.7, 0);
|
||||
const above = bot.blockAt(head.offset(0, 0.5, 0));
|
||||
if (!above || above.name === "air" || above.name === "cave_air") {
|
||||
bot.setControlState("jump", true);
|
||||
bot.setControlState("forward", true);
|
||||
await new Promise((r) => setTimeout(r, 700));
|
||||
bot.setControlState("jump", false);
|
||||
bot.setControlState("forward", false);
|
||||
continue;
|
||||
}
|
||||
try { await withTimeout(bot.lookAt(above.position.offset(0.5, 0.5, 0.5), true), 1_500, "lookAt-up"); } catch {}
|
||||
try {
|
||||
await withTimeout(bot.dig(above), 8_000, "dig-up");
|
||||
} catch (e) {
|
||||
warn("action", `escape-pit dig-up failed: ${e.message}`);
|
||||
break;
|
||||
}
|
||||
bot.setControlState("jump", true);
|
||||
await new Promise((r) => setTimeout(r, 600));
|
||||
bot.setControlState("jump", false);
|
||||
await new Promise((r) => setTimeout(r, 400));
|
||||
}
|
||||
}
|
||||
|
||||
async function probeCardinalStep(bot, durationMs = 800) {
|
||||
const trials = [];
|
||||
for (const { name, yaw } of CARDINAL_YAWS) {
|
||||
|
||||
Reference in New Issue
Block a user