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 -1
View File
@@ -54,13 +54,38 @@ test("L0 alive: zero food and have food → eat", () => {
assert.equal(n.pursue(s).skillId, "survive.eat");
});
test("L0 alive: zero food and no food → acquire", () => {
test("L0 alive: zero food and no visible target → scout-food", () => {
const n = getNeed("alive");
const s = snap({ food: 0, hasFood: false });
assert.equal(n.detect(s), false);
assert.equal(n.pursue(s).skillId, "survive.scout-food");
});
test("L0 alive: zero food with visible passive → acquire", () => {
const n = getNeed("alive");
const s = snap({
food: 0,
hasFood: false,
nearbyEntities: { passives: [{ name: "cow", distance: 12 }], droppedItems: [] },
});
assert.equal(n.detect(s), false);
assert.equal(n.pursue(s).skillId, "survive.acquire-food");
});
test("L0 alive: far or non-food passives do not trigger local acquire", () => {
const n = getNeed("alive");
assert.equal(n.pursue(snap({
food: 0,
hasFood: false,
nearbyEntities: { passives: [{ name: "chicken", distance: 51 }], droppedItems: [] },
})).skillId, "survive.scout-food");
assert.equal(n.pursue(snap({
food: 0,
hasFood: false,
nearbyEntities: { passives: [{ name: "cod", distance: 12 }], droppedItems: [] },
})).skillId, "survive.scout-food");
});
test("L1 food: 6+ food items → satisfied", () => {
const n = getNeed("food");
assert.equal(n.detect(snap({ food: 10, inventory: { bread: 6 } })), true);
@@ -73,6 +98,13 @@ test("L1 food: full saturation + any food → satisfied (no panic gathering)", (
assert.equal(n.detect(snap({ food: 20, inventory: { bread: 3 } })), true);
});
test("L1 food: no local food target uses scout-food instead of local acquire loop", () => {
const n = getNeed("food");
const s = snap({ food: 10, hasFood: false, inventory: {} });
assert.equal(n.detect(s), false);
assert.equal(n.pursue(s).skillId, "survive.scout-food");
});
test("L2 tools_wood: starts with no logs → gather.logs", () => {
const n = getNeed("tools_wood");
const s = snap();
@@ -105,6 +137,7 @@ test("L2 tools_wood: progression to pickaxe → axe → sword", () => {
test("L3 shelter_basic: bed nearby → satisfied", () => {
const n = getNeed("shelter_basic");
assert.equal(n.detect(snap({ nearbyBlocks: { beds: 1 } })), true);
assert.equal(n.detect(snap({ nearbyBlocks: { beds: { count: 1 } } })), true);
assert.equal(n.detect(snap({ inventory: { red_bed: 1 } })), true);
assert.equal(n.detect(snap()), false);
});
@@ -169,6 +202,7 @@ test("L8 armor_iron: iron_chestplate equipped → satisfied", () => {
test("L9 village_seed: bed + storage nearby → satisfied", () => {
const n = getNeed("village_seed");
assert.equal(n.detect(snap({ nearbyBlocks: { beds: 1, storage: 1 } })), true);
assert.equal(n.detect(snap({ nearbyBlocks: { beds: { count: 1 }, storage: { count: 1 } } })), true);
});
test("L9 village_seed: no chest → craft.chest if enough planks", () => {