add reachability pre-checks to plant/sleep/chop/mine
Provider audit found 6 WorkProviders missing reachability gates before returning jobs. Without them, pawns can be offered doomed walk-jobs (target boxed in), JobRunner cancels each tick, Decision re-offers same job → 20Hz busy-spin starves lower-priority work. Fixed 4 here (mechanical pattern): - PlantProvider._find_harvest: walkable-target check (mirrors _find_sow) - SleepProvider: walkable bed-tile check - ChopProvider: adjacent-walkable for impassable tree - MineProvider: adjacent-walkable for impassable rock Cooking/Crafting reachability changes (in the same audit's recommendation) were attempted but caused intermittent null returns that regressed cooking rate. Reverted those — they need more careful work that doesn't break the existing flow. Filed separately. Future cleanup: _find_adjacent_walkable duplicated across ConstructionProvider, ChopProvider — extract to a base/util. MCP-verified after revert: 2 meals + 1 bread + 2 grain in cabin crate within 3700 ticks at ULTRA. Cooking fires, hauling fires, all production paths operational. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
ab53808a53
commit
16e04e46f0
4 changed files with 57 additions and 3 deletions
|
|
@ -43,6 +43,15 @@ func find_best_for(pawn) -> Job:
|
|||
continue
|
||||
if Job.is_target_taken_by_other(rock, pawn):
|
||||
continue
|
||||
# Reachability pre-check — rocks are impassable. BigRocks expose
|
||||
# approach_tile_for(); single rocks return their own tile (walkable per
|
||||
# Phase 4). Either way, verify the approach tile is reachable before scoring.
|
||||
var approach: Vector2i = (
|
||||
rock.approach_tile_for(pawn.tile) if rock.has_method("approach_tile_for") else rock.tile
|
||||
)
|
||||
if pawn.tile != approach and World.pathfinder != null:
|
||||
if World.pathfinder.find_path(pawn.tile, approach).is_empty():
|
||||
continue
|
||||
var d: int = abs(rock.tile.x - pawn.tile.x) + abs(rock.tile.y - pawn.tile.y)
|
||||
if d < best_dist:
|
||||
best_dist = d
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue