feat(runtime): autonomous reflex — chop + wander + proactive movement #8

Merged
halofourteen merged 1 commits from feat/autonomous-reflex into main 2026-05-25 16:40:36 +03:00
halofourteen commented 2026-05-25 16:40:29 +03:00 (Migrated from github.com)

Summary

Fixes the "bot stands on a tree doing nothing" report from the live TUI test after PR #6 landed. Reactive chain (operator > defend > eat > sleep > idle) is passive by design — day, full HP/food, no hostile within 4m ⇒ every reflex noops. Bot perched in dark-oak canopy and never moved.

New things

  • `autonomousReflex` between sleep and idle. Picks chop (if log inventory < 16) or wander. Cooldown 10s. When chop reports "no reachable log within 32 blocks", switches to wander for 60s.
  • `chopNearestTree` action: find any `*_log` within 32 blocks, equip best axe (or fists), path + dig. Per-bot 5-min blacklist of unreachable positions so we don't grind on the same impossible target.
  • `wander` action: random offset 6-16 blocks away, pathfind there.
  • Movements profiles explicit per action. Old behaviour: chop inherited `canDig=false` from a previous flee and got stuck in canopy. Now both gather and travel use `canDig=true`. Flee too — the user saw the bot stuck on a leaf block because escape required digging.
  • Player chat replies: light canned greetings (`yo`, `hey`, `hi`, `привет`) when a non-operator addresses the bot. 30s cooldown.
  • TUI: status bar now shows either `▸ busy: ` (action in flight) or `last reflex: () Ns ago` (idle). Answers "what is the bot doing right now?" at a glance.

Defensive tweaks

  • defendReflex tightened: flee only when closest mob ≤8m (or ≤12m on low HP). Fixes "82 distant hostiles ⇒ constant flee loop" observed at this spawn.
  • flee cooldown: same mob name within 60s ⇒ noop. Yields to other reflexes when flee keeps timing out.
  • sleepReflex retry cooldown 30s → 5min. Sleeping fails permanently if no bed is around; the short retry was blocking autonomous behaviour every tick.

Live smoke test (play.xmatic.team, 2026-05-25T13:30-13:39)

  1. Bot dispatched `chop tree` (oak_log at 617,82,95) — first proactive action since PR #6.
  2. A real bug surfaced in my matcher (`b.position` could be null). The 3-fail rule automatically filed a proposal (`2026-05-25T13-37-03-repeated-fail-chop-tree.md`). Self-improvement loop demonstrated end-to-end.
  3. After the matcher fix, `chopNearestTree` returns `"no reachable log within 32 blocks"` gracefully.
  4. Bot switched to wander on the next tick: `dispatch: → wander → 625,85,103 (8.5m)`.
  5. Position moved from (623.31, 85, 95.12) to (623.41, 86.02, 96.7) — the first observable movement in this dark-oak spawn.

Known follow-ups

  • Proposal cooldown is process-local; supervisor restart resets `lastProposalAt`. Should persist via state-store. Not blocking — proposals are cheap files.
  • Bot can still get stuck high in canopy when pathfinder can't compute a descent. Adding a "fall through leaves" action would unstick it; for now wander + canDig usually works it out.

🤖 Generated with Claude Code

## Summary Fixes the "bot stands on a tree doing nothing" report from the live TUI test after PR #6 landed. Reactive chain (operator > defend > eat > sleep > idle) is **passive by design** — day, full HP/food, no hostile within 4m ⇒ every reflex noops. Bot perched in dark-oak canopy and never moved. ## New things - **\`autonomousReflex\`** between sleep and idle. Picks chop (if log inventory < 16) or wander. Cooldown 10s. When chop reports "no reachable log within 32 blocks", switches to wander for 60s. - **\`chopNearestTree\`** action: find any \`*_log\` within 32 blocks, equip best axe (or fists), path + dig. Per-bot 5-min blacklist of unreachable positions so we don't grind on the same impossible target. - **\`wander\`** action: random offset 6-16 blocks away, pathfind there. - **Movements profiles** explicit per action. Old behaviour: chop inherited \`canDig=false\` from a previous flee and got stuck in canopy. Now both gather and travel use \`canDig=true\`. Flee too — the user saw the bot stuck on a leaf block because escape required digging. - **Player chat replies**: light canned greetings (\`yo\`, \`hey\`, \`hi\`, \`привет\`) when a non-operator addresses the bot. 30s cooldown. - **TUI**: status bar now shows either \`▸ busy: <label>\` (action in flight) or \`last reflex: <name> (<label>) Ns ago\` (idle). Answers "what is the bot doing right now?" at a glance. ## Defensive tweaks - **defendReflex** tightened: flee only when closest mob ≤8m (or ≤12m on low HP). Fixes "82 distant hostiles ⇒ constant flee loop" observed at this spawn. - **flee cooldown**: same mob name within 60s ⇒ noop. Yields to other reflexes when flee keeps timing out. - **sleepReflex** retry cooldown 30s → 5min. Sleeping fails permanently if no bed is around; the short retry was blocking autonomous behaviour every tick. ## Live smoke test (play.xmatic.team, 2026-05-25T13:30-13:39) 1. Bot dispatched \`chop tree\` (oak_log at 617,82,95) — first proactive action since PR #6. 2. A real bug surfaced in my matcher (\`b.position\` could be null). The 3-fail rule **automatically filed a proposal** (\`2026-05-25T13-37-03-repeated-fail-chop-tree.md\`). Self-improvement loop demonstrated end-to-end. 3. After the matcher fix, \`chopNearestTree\` returns \`"no reachable log within 32 blocks"\` gracefully. 4. Bot switched to wander on the next tick: \`dispatch: → wander → 625,85,103 (8.5m)\`. 5. **Position moved** from (623.31, 85, 95.12) to (623.41, 86.02, 96.7) — the first observable movement in this dark-oak spawn. ## Known follow-ups - Proposal cooldown is process-local; supervisor restart resets \`lastProposalAt\`. Should persist via state-store. Not blocking — proposals are cheap files. - Bot can still get stuck high in canopy when pathfinder can't compute a descent. Adding a "fall through leaves" action would unstick it; for now wander + canDig usually works it out. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.