🐛 Nisse stuck idle: keeps retrying unreachable trees in dense forest #22

Closed
opened 2026-03-23 11:42:44 +00:00 by claude · 0 comments
Collaborator

Bug

Nisse repeatedly pick a chop/mine job, fail to pathfind, and loop every ~1.5 s. Work log fills up with identical "Walking to chop at (X, Y)" entries; the Nisse never actually works and stands idle in the stockpile.

Root cause

A* allows the goal tile to be impassable (the isGoal bypass in pathfinding.ts line 50), but it still needs at least one passable neighbour of the goal tile to jump from. Trees deep inside a dense forest cluster have all 8 adjacent tiles set to FOREST (impassable) — A* can never reach the goal, returns null every time. The Nisse then unclams the target and retries after 1.5 s, creating an infinite loop.

Fix

  • pickJob now filters out any chop/mine target where hasAdjacentPassable() returns false — trees/rocks with no reachable neighbour are never added to the candidate list.
  • idleScanTimer on pathfind failure increased 1 500 ms → 4 000 ms as an additional safety net for edge cases where the adjacent check passes but the full path still fails (e.g. isolated pocket unreachable from the Nisse's current position).
## Bug Nisse repeatedly pick a chop/mine job, fail to pathfind, and loop every ~1.5 s. Work log fills up with identical "Walking to chop at (X, Y)" entries; the Nisse never actually works and stands idle in the stockpile. ## Root cause A* allows the goal tile to be impassable (the `isGoal` bypass in pathfinding.ts line 50), but it still needs at least one **passable neighbour** of the goal tile to jump from. Trees deep inside a dense forest cluster have all 8 adjacent tiles set to FOREST (impassable) — A* can never reach the goal, returns `null` every time. The Nisse then unclams the target and retries after 1.5 s, creating an infinite loop. ## Fix - `pickJob` now filters out any chop/mine target where `hasAdjacentPassable()` returns false — trees/rocks with no reachable neighbour are never added to the candidate list. - `idleScanTimer` on pathfind failure increased 1 500 ms → 4 000 ms as an additional safety net for edge cases where the adjacent check passes but the full path still fails (e.g. isolated pocket unreachable from the Nisse's current position).
claude added the
bug
status: ready
labels 2026-03-23 11:42:48 +00:00
claude added
status: done
and removed
status: ready
labels 2026-03-23 12:29:30 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: tekki/nissefolk#22
No description provided.