feat(sim,render,save): finite food piles with runtime respawn (closes #112)#113
Merged
Merged
Conversation
…112) Food piles previously existed as infinite static markers seeded at scenario start. They now drain by pickup-charges and a runtime spawner places fresh piles on a time-based cadence — turning food into a strategic survival mechanic where colonies must redirect foraging when nearby sources deplete. Sim changes: - FoodPile gains pickupsRemaining + pickupsInitial (charge counter; distinct from the fixed-point food quantity transferred per pickup, which stays at FOOD_PICKUP_AMOUNT). antPickupFood drains FOOD_PILE_PICKUP_DRAIN charges per successful transfer; tickForagerActions splices the pile and records the depletion when charges hit zero. - New tick step 16d (tickFoodPileSpawn) runs after tickNurseActions, before combat. Time-gated (every FOOD_PILE_SPAWN_INTERVAL_TICKS = 1800 ticks / 90s at 20Hz), soft-ceiling at FOOD_PILE_COUNT * 2 = 30. Placement uses rejection sampling with grass-weighted RNG and rejects tiles near colonies, entrances, rally points, existing piles, and recently-depleted tiles (anti-teleport guard). - WorldState gains recentlyDepletedFood: bounded ring-buffer-style array (cap = soft ceiling, append-time shift) to prevent jarring "pile vanished here, instantly reappeared next door" placements while pheromone trails decay naturally. - Scenario seeding's pickup-charge draw uses a deterministic hash of (terrainSeed, foodPileId) instead of advancing the world RNG, preserving byte-identical replay for every existing test. Render: surface piles now visibly shrink across 4 size buckets keyed on pickupsRemaining/pickupsInitial — both small ephemeral piles and large strategic anchors visibly drain across their lifetime. Save format: bumped to v3 (SAVE_KEY = 'subterrans:save:v3'). v2 saves are rejected on load via the existing SaveVersionMismatchError flow per the "intentional for beta" policy. Validators check pickup-charge fields (pickupsInitial in [MIN, MAX], pickupsRemaining in [1, pickupsInitial]) and the new recentlyDepletedFood array. Tests: 1936 passing (1901 → 1936). New coverage in food-system.test.ts (spawn gating, placement constraints, determinism, entity-ID exhaustion, tick-dispatcher integration), pheromone/food-trail-decays-after-depletion test (verifies the design's "self-balancing" claim), save.test.ts updates (v2 reject via parseSaveFile, validator strictness), and types.test.ts copyWorldState round-trip coverage for the new field. Default balance numbers (initial pickups 20-150, drain 1/pickup, spawn ~90s, grass weight 4:1) are best-guesses pending playtest retune. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Owner
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #112. Food piles previously existed as infinite static markers seeded at scenario start. They now drain by pickup-charges and a runtime spawner places fresh piles on a time-based cadence — turning food into a strategic survival mechanic where colonies must redirect foraging when nearby sources deplete.
Design lock and rationale lives at #112 (planning thread, not duplicated here).
Determinism / boundary
Defaults flagged for retune
Per the issue planning thread, these defaults are best-guesses pending playtest:
Test plan
Sim version
No `LATEST_SIM_VERSION` bump. Save-format bump rejects all v2 saves outright, so every save the engine ever loads is post-spawn-mechanic — no surface where old data needs to replay under "no spawn" behaviour gates.
🤖 Generated with Claude Code