Skip to content

Safety Net en

ZoyLuo edited this page Jun 5, 2026 · 1 revision

Safety Net

Whatever the upper layers decide, AIBot runs a per-tick safety net that keeps the bot from needlessly dying. This is key to it feeling "alive".

Per-tick pipeline

Scheduled by BotTickCoordinator in a fixed order. Whichever layer takes over short-circuits the tick (later layers don't run):

① NavSafetyNet  →  ② StuckWatcher  →  ③ DangerWatcher  →  ④ GoalExecutor  →  ⑤ IdleCoordinator
   survival          anti-stuck         fight/flee/avoid     advance goal        autonomy

① NavSafetyNet — environmental survival (highest priority)

  • Suffocation: stuck in blocks → climb up to the surface (fixes "rescue digs it deeper").
  • Lava: standing in / on lava → escape immediately.
  • Drowning: underwater and low on air → surface to breathe; if sealed in with no air, emergency-teleport to the nearest breathable spot.

② StuckWatcher — stuck detection

Within watchdog.stuckWindowTicks, if position, task progress and inventory total are all unchanged, it declares a stuck and aborts the task, handing back to the upper layer to re-plan.

Stationary tasks (mining / descending) opt out via isWaiting() and rely on their own watchdog — avoiding false kills while working. See Task System.

③ DangerWatcher — threat response

  • Threat detection: collectTopThreat scans nearby hostiles with line-of-sight / block-occlusion checks (no "fighting through a wall" false positives).
  • Fight or flee: decideCombatOrEvade weighs HP and enemy count (combat.retreatHp / maxEnemiesToFight).
  • Light the dark: place torches when light is too low, reducing spawns at the source.
  • Dark-trap escape: maybeEscapeDarkTrap retreats to the surface when swarmed; the goal is kept so the bot resumes the unfinished task afterward (no "amnesia on retreat").

④ GoalExecutor — advance the goal

With no danger, advance the next step of the current Goal Engine; re-plan on failure.

⑤ IdleCoordinator — autonomy

With no goal or task, the bot decides what to do (organize, patrol, stand by) instead of freezing.

Human-like safety hardening

  • Dig-move circuit breaker: the moment MoveTask digs the bot underwater (drowning) or into a mob pit (taking hits), it abandons the move and hands off to the safety net — never digging all the way to death.
  • Staircase descent: DescendToYTask / DigDownTask always dig diagonally down, avoiding water / lava below — never straight down into a void.
  • No teleporting, no bunny-hopping: walking only taps jump once, when grounded and a real step / gap is ahead.

Further reading: Architecture · Task System · Configuration (tuning thresholds)

Clone this wiki locally