fix(v0.3.1): mechanical food/stuck fixes — bot reaches the chicken now

The wedge wasn't only in the manifesto layer; several mechanical bugs
kept the bot in a dead random-walk:

- storyline / manifesto / curriculum: "local food" now means an edible
  passive mob within <=32 blocks. A distant chicken or a cod no longer
  fools the bot into dispatching acquire-food (which then fails on
  no_path). Long-range food goes through scout-food instead.

- scout-food: partial approach to a target now counts as progress
  (approached_target, e.g. moved:14); a blocked heading is NOT counted
  as movement; added blind/tunnel fallback so it doesn't die when the
  pathfinder can't route cleanly.

- acquire-food: on no_path it now also tries a blind/tunnel approach to
  the animal; no_drop routes back into food scouting instead of giving
  up.

- explore.far / relocate / flee: fewer false "done" results (micro-steps
  no longer counted as success), more genuine escapes from stuck.

- scripts/show-story.js: live IPC now actually renders the current
  storyline step.

Verification: scripts/lint-patch.js clean; npm test 404/404 green; bot
relaunched in tmux `pepa`. Live logs show real progress — bot switched
to survive.scout-food, approached the chicken (approached_target
moved:14), then reached survive.acquire-food: hunting chicken. Food
isn't fully closed yet but the remaining issue is concrete pickup/drop,
not dead random-walk.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-28 09:20:07 +03:00
co-authored by Claude Opus 4.7
parent b68d4b3ee7
commit 1cf60f81e9
19 changed files with 548 additions and 106 deletions
+35 -4
View File
@@ -37,7 +37,7 @@ test("STORYLINE: 11 steps, all have id/title/narration/completed/suggestSkill",
});
test("getStep: lookup by id", () => {
assert.equal(getStep("first_wood").title, "Собрать 8 поленьев");
assert.equal(getStep("first_wood").title, "Собрать стартовое дерево");
assert.equal(getStep("does-not-exist"), null);
});
@@ -49,16 +49,18 @@ test("emergencyPause: low hp + close hostile → true", () => {
assert.equal(emergencyPause(snap({ food: 0 })), true);
});
test("step first_wood: completed when ≥8 logs", () => {
test("step first_wood: completed when bootstrap wood budget is enough", () => {
const s = getStep("first_wood");
assert.equal(s.completed(snap()), false);
assert.equal(s.completed(snap({ inventory: { oak_log: 8 } })), true);
assert.equal(s.completed(snap({ inventory: { oak_log: 4, birch_log: 4 } })), true);
assert.equal(s.completed(snap({ inventory: { oak_log: 4 } })), true);
assert.equal(s.completed(snap({ inventory: { oak_log: 2, oak_planks: 8 } })), true);
assert.equal(s.completed(snap({ inventory: { wooden_pickaxe: 1 } })), true);
});
test("step first_wood: suggest gather.logs if trees nearby, explore.far otherwise", () => {
const s = getStep("first_wood");
assert.equal(s.suggestSkill(snap({ nearbyBlocks: { logs: 5 } })).skillId, "gather.logs");
assert.equal(s.suggestSkill(snap({ nearbyBlocks: { logs: { count: 1 } } })).skillId, "gather.logs");
assert.equal(s.suggestSkill(snap()).skillId, "explore.far");
});
@@ -77,10 +79,27 @@ test("step first_food: completed at ≥2 food items", () => {
assert.equal(s.completed(snap({ inventory: { bread: 2 } })), true);
});
test("step first_food: local hunt only for edible passive mobs within acquire range", () => {
const s = getStep("first_food");
assert.equal(
s.suggestSkill(snap({ nearbyEntities: { passives: [{ name: "chicken", distance: 18 }] } })).skillId,
"survive.acquire-food",
);
assert.equal(
s.suggestSkill(snap({ nearbyEntities: { passives: [{ name: "chicken", distance: 51 }] } })).skillId,
"survive.scout-food",
);
assert.equal(
s.suggestSkill(snap({ nearbyEntities: { passives: [{ name: "cod", distance: 12 }] } })).skillId,
"survive.scout-food",
);
});
test("step shelter_minimal: completed when bed placed nearby", () => {
const s = getStep("shelter_minimal");
assert.equal(s.completed(snap()), false);
assert.equal(s.completed(snap({ nearbyBlocks: { beds: 1 } })), true);
assert.equal(s.completed(snap({ nearbyBlocks: { beds: { count: 1 } } })), true);
});
test("step stone_tier: needs cobblestone first", () => {
@@ -133,6 +152,18 @@ test("pickCurrentStep: bot with 8+ logs → first_wood done, picks crafting_basi
assert.equal(r.completedSteps, 2, "orient_self + first_wood done");
});
test("pickCurrentStep: bot with planks and sticks advances to first_tools", () => {
_resetForTest();
const r = pickCurrentStep(snap({
_sessionMs: 60_000,
nearbyBlocks: { logs: { count: 3 } },
inventory: { oak_planks: 16, stick: 4 },
}));
assert.ok(r);
assert.equal(r.step.id, "first_tools");
assert.equal(r.suggestion.skillId, "craft.wooden-pickaxe");
});
test("pickCurrentStep: emergency pauses suggestion", () => {
_resetForTest();
const r = pickCurrentStep(snap({