Commit Graph
198 Commits
Author SHA1 Message Date
popertots c9d74ef49b Update z-level context: not underground, perlin terrain, check working pathfinding 2026-04-04 12:29:03 +01:00
popertots f054bf25f1 Add session continuation prompt for next agent 2026-04-04 12:21:52 +01:00
popertots 8e3e8b8b8c Fix: Set ambulatory.target for HaulCargo when approach pre-computed
When job_pathfinding pre-computes the approach tile for HaulCargo,
the executor was skipping target assignment because:
1. approach.is_none() was false (approach already set)
2. ambulatory.target.is_none() was true (no target set)
3. No else branch to set the target

Added else-if branch to set target when approach is set but target isn't.
This fixes dorfs freezing in MovingToCargo state with target=None.
2026-04-04 12:16:23 +01:00
popertots 022e21d484 Fix: Don't clear ambulatory.target during job assignment
The target oscillation was caused by job_pathfinding_system
clearing ambulatory.target = None on assignment, then the executor
setting it to approach, then job_pathfinding clearing it again
the next frame.

By not clearing ambulatory.target, the executor sets it once
and it persists until the task completes.
2026-04-04 12:02:15 +01:00
popertots 7cf1b83427 Fix: Allow dorfs running Idle task to be job candidates
The bug: We excluded ALL Active state dorfs, but Idle tasks get
immediately promoted from Pending to Active by task_executor_system.
So by the time job_pathfinding runs, all dorfs are Active with Idle.

The fix: Check if dorf is 'busy' = Active AND non-Idle task.
Dorfs with Idle tasks (even in Active state) can be interrupted
for real jobs.
2026-04-04 11:53:29 +01:00
popertots 196ff9cec4 Fix job pathfinding: allow idle dorfs to be candidates + add debug logging
KEY FIX: Changed candidate filter to allow dorfs with Idle tasks:
- Before: Only dorfs with empty queues were candidates
- After: Dorfs with empty queue OR Idle task are candidates
- This fixes deadlock where all dorfs had Idle tasks and were excluded

Debug logging added:
- job_pathfinding.rs: Log job processing, candidate counts, path results
- queue_debug.rs: Show job state (Unclaimed/Calculating/Claimed/Suspended), retry count, and dorf idle status

The bug was that job_pathfinding_system filtered out ALL dorfs because:
1. job_assignment_system gave Idle tasks to dorfs with empty queues
2. task_executor_system promoted them to Active
3. job_pathfinding_system then excluded Active dorfs AND non-empty queues
2026-04-04 11:50:10 +01:00
popertots 053fe415bf Implement async job pathfinding system
- Add calculate_traversal_distance() - full A* that returns actual distance
- Add batch_calculate_traversals() for efficient batch processing
- Add Calculating state to JobState enum for dorf locking
- Add approach_target and retry_count to job Entry
- Add helper methods: is_dorf_locked, get_locked_dorfs, get_scope_for_job
- Add job_assignment config section with max_dorfs_per_job
- Create job_pathfinding.rs with main pathfinding system:
  - Throttled to MAX_JOBS_PER_TICK (5) per frame
  - Expanding scope: 5 -> 20 -> 200 dorfs based on retry count
  - Uses full pathfinding, not provisional
  - Pre-computes approach_target for assigned dorfs
- Simplify job_assignment.rs to only handle idle fallback
- Update has_fell_tree to check state (Unclaimed, Calculating, Claimed)
2026-03-29 13:13:53 +01:00
popertots 3c74a68d4d Refactor job queue: add JobState enum, improve pathfinding fallback
- Add JobState enum (Unclaimed, Claimed, Complete) replacing boolean claimed flag
- Increase provisional node limit from 256 to 4096
- Add iter_unclaimed() and claim_job_at() methods to JobQueue
- Update job_assignment to filter idle dorfs, match by distance
- Add unclaim_jobs_for_entity() for handling dorf death/failure
- Add JobId collision detection in debug builds
- Fix demo system to check Pending state for chopping dorfs
- Throttle queue_debug to every 120 ticks
- Add surface position deduplication for terrain chunks
2026-03-29 13:02:05 +01:00
popertots 79e0efa409 Fix job queueing system: add JobId tracking for failed job reassignment
- Add JobId (rolling u16 counter) to track jobs through their lifecycle
- Add job_id field to all Task variants (Idle, GoTo, ChopTree, HaulCargo, DropHauled)
- Add unclaim_job() method to requeue failed jobs for reassignment
- Change task failure paths to use unclaim_job() instead of complete_job_by_id()
  - This allows failed jobs to be picked up by another dorf instead of being stuck
- Add to_job_kind() and get_job_id() helper methods to Task
- Fix pathfinding is_standable_tile debug logging spam
- Fix chunk bounds check in ChunkData::is_standable (was checking wrong z range)
2026-03-27 20:28:58 +00:00
popertots bd1b45e4d7 attempt 3 2026-03-27 10:29:33 +00:00
popertots 1f5dfe5182 Task fix attempt 2026-03-23 19:31:30 +00:00
popertots 3632836016 fix 2026-03-22 22:30:15 +00:00
popertots bf81f42ced fix 2026-03-22 22:10:00 +00:00
popertots 57764fbcbb fix 2026-03-22 22:05:08 +00:00
popertots c448ef4bff fix 2026-03-22 22:01:11 +00:00
popertots 760f6602cf fix 2026-03-22 16:51:20 +00:00
popertots ffb0e79cf3 fix 2026-03-22 16:45:46 +00:00
popertots 738f595f67 debug 2026-03-22 16:38:54 +00:00
popertots e7a43457a3 fix 2026-03-22 16:05:38 +00:00
popertots bceec18a7a log sprite 2026-03-22 16:05:33 +00:00
popertots c46e23af06 fix 2026-03-22 15:23:44 +00:00
popertots 3b9b2d9c88 fix 2026-03-22 15:07:05 +00:00
popertots 5a830f46f9 demo part 2 2026-03-22 14:57:59 +00:00
popertots 54eabe85e2 fix 2026-03-22 14:34:59 +00:00
popertots 57e377c093 fix 2026-03-22 13:01:10 +00:00
popertots 2eaf0196a5 demo 1 2026-03-22 12:56:52 +00:00
popertots 360ffc7526 value tweaks 2026-03-22 12:06:33 +00:00
popertots 26a861e1a5 value tweaks 2026-03-22 12:00:17 +00:00
popertots cb5b18008d fix 2026-03-22 11:50:53 +00:00
popertots 2f456f80b8 Gaussian idle 2026-03-22 11:29:50 +00:00
popertots b2dc0cb864 fix 2026-03-22 11:02:36 +00:00
popertots 749913a028 fix? 2026-03-22 01:58:34 +00:00
popertots adc236dc3d fix 2026-03-22 01:52:20 +00:00
popertots 9afcb0f612 more debug 2026-03-22 01:32:22 +00:00
popertots 64a69d6a40 Debug 2026-03-22 01:24:08 +00:00
popertots deb3f741b0 rng fix 2026-03-22 01:00:42 +00:00
popertots 71653350d8 fix 2026-03-22 00:52:06 +00:00
popertots cafe376841 Plugin cleanup 2026-03-22 00:43:03 +00:00
popertots d61baaf1ba Task Infrastructure — Task Enum, Queue, Events, Executor 2026-03-22 00:35:22 +00:00
popertots 458068fb87 run_if 2026-03-22 00:03:57 +00:00
popertots ff149117ca remove Digger from dorf 2026-03-21 23:56:03 +00:00
popertots 029e4162d8 fixes 2026-03-21 23:48:49 +00:00
popertots c776b91a44 haulage system WIP 2026-03-21 23:39:58 +00:00
popertots dcdfb375f0 Fix 2026-03-21 21:51:29 +00:00
popertots f52c8ab18c inventory: early return before HashSet alloc, restore doc comments 2026-03-21 21:44:06 +00:00
popertots b7b7af5560 inventory: linter fixes - saturating_add, SmallVec<4>, new_default, drop PIG_SLOTS 2026-03-21 21:39:52 +00:00
popertots 2f9360c8bc inv update 2026-03-21 21:27:26 +00:00
popertots 40b5d8ce95 Fix forrestry 2026-03-21 19:20:57 +00:00
popertots 1ddcb538df tree felling optimisations 2026-03-21 19:14:14 +00:00
popertots 4fc4843ed7 fix 2026-03-21 19:10:04 +00:00