Pawn work loop: claim, navigate, work, complete #75
Labels
No labels
assets
bug
duplicate
enhancement
help wanted
invalid
question
testing
ui
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Blocks
#117 Multi-pawn work slots, opted into per site
liamjd/UntitledColonyBuilder
Reference
liamjd/UntitledColonyBuilder#75
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Part of milestone #5. Depends on #65, #67 and #70. Blocked by milestone #4 for navigation.
The consumer side of the task system. Everything before this is testable without a pawn moving; this is where it becomes visible.
AC:
next_for(self)on eachGameClocktick (not every frame)target_celltask.work()once per tick untilwork_remainingreaches zero, then completes the task through the managerSpec written, on branch
75-pawn-work-loop:test/unit/test_pawn_work_loop.gd, 20 tests, 18 red. The two that pass assert that nothing happens — an empty queue, and a registry with noTaskManager— which a no-op loop satisfies correctly.Most of this issue already exists.
next_for()hands out tasks (#67),move_to()walks a pawn to a cell, arrival flips it to WORKING when it lands on the target cell (#112), and the manager's completed/cancelled/released signals clear the task off the pawn again. What is missing is the driver: nothing in the game connects toGameClock.tick, so a placed building sits PLANNED forever with a task in the queue nobody asks for.The seam
Pawns.on_tick(run_tick: int), declared with an empty body so the spec compiles, plusPawns.EFFORT_PER_TICK = 1.0. The loop is amatchonpawn.state:next_for(pawn.id); null ends the tick. Otherwiseclaim(),assign_task(), then eithermove_to(target_cell)or, if the pawn is already standing on it, WORKING directly.start()if the task is still CLAIMED, thenwork(ctx, EFFORT_PER_TICK), thencomplete()whenwork_remaininghits zero.Decisions taken in the spec
Each of these is pinned by a test, so overruling one means changing a test rather than discovering it later.
GameClock.tickconnection, notPawns._ready()and not thetaskssetter. GameClock is an autoload and keeps ticking through the test run; a registry that subscribed itself would have the live clock driving work in the middle of every other pawn test, and those tests would pass or fail on how long the suite took. It also matches howmapandtasksalready arrive.matchwith no fallthrough between the arms.can_start()takes a context and no pawn, so it cannot answer "reachable from where" — two pawns either side of a severed map disagree about the same task. The loop claims, callsmove_to(), and readsfalseas the answer: release, mark BLOCKED, pawn back to idle. SoTaskContext.map— the commented line annotated "required for #75" — is not required. Leave it commented or delete it; this issue should not add it.next_for()re-evaluates BLOCKED tasks back to PENDING. That is a real loop rather than an oversight, and it is cheap at ten pawns. Pinned by a test so the event-driven unblocking noted in #67 changes a test instead of arriving by surprise.debug_scatter_pawns()sends pawns walking with no task at all, and a loop that stopped every taskless walker would freeze them where they stand. Arrival is what idles it.work_remainingis in work-ticks, so a pawn working a day of ticks discharges one pawn-day — which is what makes #88's unit true rather than aspirational. Skill multipliers are #74; a second pawn on the same task is #117.Not covered by the spec
The debug panel pawn rows AC.
ui/debug_layer.gdcurrently shows seed, terrain preset, tick and the command list, and reaches its collaborators through$"../Map"and$"../Pawns", so it cannot be built standalone in a test. The rows (id, state, cell, task) are implementation plus a headed check, not something the suite can hold.The end-to-end AC — a placed building becoming BUILT — is covered headless, through a real
ConstructionTaskand a realBuildingsregistry sharing the manager: place, tick to claim, walk, and tick until BUILT. A headed run is still worth doing for the pawn rows and to watch it happen.