🐛 Skip unreachable job targets in pickJob #23

Merged
claude merged 3 commits from fix/unreachable-job-skip into master 2026-03-23 12:29:18 +00:00
Collaborator

Fixes #22.

What changed

  • New helper hasAdjacentPassable(): checks all 8 neighbours of a tile for passability
  • pickJob filters out chop/mine candidates where no passable neighbour exists — these trees/rocks are unreachable by A* regardless of path length
  • idleScanTimer on pathfind failure raised 1 500 → 4 000 ms as secondary safety net
Fixes #22. ## What changed - New helper hasAdjacentPassable(): checks all 8 neighbours of a tile for passability - pickJob filters out chop/mine candidates where no passable neighbour exists — these trees/rocks are unreachable by A* regardless of path length - idleScanTimer on pathfind failure raised 1 500 → 4 000 ms as secondary safety net
claude added 1 commit 2026-03-23 11:44:01 +00:00
Trees/rocks fully enclosed by impassable tiles have no passable neighbour
for A* to jump from — pathfinding always returns null, causing a tight
1.5 s retry loop that fills the work log with identical entries.

- Add hasAdjacentPassable() helper: checks all 8 neighbours of a tile
- pickJob now skips chop/mine candidates with no passable neighbour
- idleScanTimer on pathfind failure raised 1500 → 4000 ms as safety net

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
claude added 1 commit 2026-03-23 11:55:31 +00:00
Previously FOREST and ROCK tile types were always impassable, making 30 % of
forest floor and 50 % of rocky terrain permanently blocked even with no object
on them.

- Remove FOREST + ROCK from IMPASSABLE in types.ts
- Add RESOURCE_TERRAIN set (FOREST, ROCK) for tiles that need resource check
- WorldSystem: add resourceTiles Set<number> as O(1) spatial index
  - initResourceTiles() builds index from state on create()
  - addResourceTile() / removeResourceTile() keep it in sync at runtime
- isPassable() now: impassable tiles → false | RESOURCE_TERRAIN → check index | else → true
- GameScene: call addResourceTile() when SPAWN_RESOURCE fires (seedling matures)
- VillagerSystem: call removeResourceTile() after chop / mine completes

Side effect: trees fully enclosed by other trees are now reachable once an
adjacent tree is cleared; the hasAdjacentPassable() guard in pickJob still
correctly skips resources with zero passable neighbours.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
claude added 1 commit 2026-03-23 12:21:31 +00:00
CHANGE_TILE only called worldSystem.setTile() (built-tile layer only),
never refreshTerrainTile() — so chopped trees stayed visually dark-green
(FOREST color) even though the tile type was already DARK_GRASS.

- adapter.onAction for CHANGE_TILE now also calls refreshTerrainTile()
  → all tile transitions (chop, mine, seedling maturation) update the
    canvas pixel immediately and consistently in one place
- Remove now-redundant explicit refreshTerrainTile() call in
  TreeSeedlingSystem (the adapter handler covers it)
- Tile-recovery path in GameScene (stateManager.tickTileRecovery) is
  NOT routed through the adapter, so its manual refreshTerrainTile()
  call is kept as-is

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
tekki approved these changes 2026-03-23 12:29:02 +00:00
claude merged commit 8197348cfc into master 2026-03-23 12:29:18 +00:00
claude deleted branch fix/unreachable-job-skip 2026-03-23 12:29:18 +00:00
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: tekki/nissefolk#23
No description provided.