Repository navigation
M2: villagers gather (deposits as rows, halls and stockpiles, sparse resources) - #41
Open
CodeByBryant wants to merge 12 commits into
Open
CodeByBryant wants to merge 12 commits into
CodeByBryant wants to merge 12 commits into
Conversation
Every deposit is a row (kind, tile, stock, richness) in tile order, found by binary search, with the tile slot arrays kept as write-through views. A bytes form for the save, a changed list for the app, and an immutable grid index for 'the nearest tree'. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cn5qp59UwGNst3umuaQf6u
Stocks now live in the NodeStore and write through to the tile slot arrays, so the renderer, inspector and nation profiles are untouched. ResourceStocks works on node ids (extractNode for gatherers). The state hash covers the node block (with a new uint32 array writer and Python reference vectors) instead of six tile layers; the save ends with a binary node block and the resource layers are rebuilt on load. World.validate checks the views against the nodes. Goldens are stale until the regeneration commit. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cn5qp59UwGNst3umuaQf6u
A hall is an entity row at each capital; its stockpile (22 counters) is saved in the header and hashed. Villagers gain hall, goal, carriedType and carriedCount columns and the Work and Haul states exist (nothing uses them yet). unitPositions lists villagers only; validate checks hall references, carried stacks, goals and that every hall has a stockpile and the reverse. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cn5qp59UwGNst3umuaQf6u
UnitSystem (the old WanderSystem) now runs a gather cycle for villagers that belong to a hall: pick a kind (a counter-based draw, three tries), walk to the nearest deposit in reach (NodeIndex), work there for the rule's ticks (water deposits are worked from the shore), take what the deposit, the trip and the carry limit allow through ResourceStocks, haul it home and drop it in the hall's stockpile. Villagers with no hall or nothing in reach still wander. New states Work and Haul are validated. Config: units.carryCapacity, searchRadius and a per-resource gather table. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cn5qp59UwGNst3umuaQf6u
…ather Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cn5qp59UwGNst3umuaQf6u
Every world changes again: the resource layers are hashed as node rows, villagers and halls carry the new columns, stockpiles are hashed, and villagers now gather, which moves stocks, province facts and so nation profiles. One new entry runs 800 ticks so halls fill and deposits regrow. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cn5qp59UwGNst3umuaQf6u
ticked carries the deposits that changed in a run (applyStockChanges writes them into the app's slot arrays, which the sprites, inspector and overlays all read); ready carries the halls and starts from a clean slate of changes. Unit snapshots gain state and carried resource. Spec: hash 6 entity columns and the stockpile section. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cn5qp59UwGNst3umuaQf6u
…rld; e2e:gather; ADR 0009 Working villagers swing, haulers show what they carry, halls come from the new halls list, the resource overlay is redrawn (throttled) as stock deltas arrive, and the canvas publishes working, carrying and drawn-down counts for the e2e. ADR 0009, roadmap and development docs. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cn5qp59UwGNst3umuaQf6u
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cn5qp59UwGNst3umuaQf6u
A rule can ask for spacing: tiles are still taken best first, but one is skipped if an object of the same kind is closer than that, so a patch is a scatter with open ground between instead of a solid block. The default rules drop their shares and ask for room (timber 3.5% of land at spacing 2, etc.): around the first capital 15% of land tiles hold a surface resource instead of 74%. Guards now check that objects are grouped, not speckled, and that spaced ones never touch. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cn5qp59UwGNst3umuaQf6u
Every world's resources change (spacing and lower shares), so every golden hash, the terrain goldens and the depletion golden move. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cn5qp59UwGNst3umuaQf6u
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cn5qp59UwGNst3umuaQf6u
This branch has not been deployed
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
Milestone M2 of the units plan (ADR 0008, ADR 0009). Stacked on #39 (M1): the base is the M1 branch, so this diff is M2 only. Retarget to
mainonce #38 and #39 merge.Villagers now do something: each one walks to the nearest deposit of a resource it picked, works it, carries what it took home and drops it in its hall's stockpile, and you can watch the deposit shrink and regrow. Along the way the resources got thinned: the first screenshots were a solid wall of icons (74% of land tiles near a capital held a surface resource), so placement now leaves room between objects (about 15% now).
Changes
NodeStore(kind, tile, stock, richness; about 960k nodes, 6.7 MB),NodeIndex("the nearest tree"),ResourceStocksrewritten on node ids. The tile slot arrays stay as write-through views, so the renderer, inspector and nation profiles are unchanged. Hash 6, save 7 (binary node block; the 24 MB of resource layers are gone), web DB 8.EntityKind.Hallrows at each capital, 22 counters each (saved and hashed), four new villager columns (hall,goal,carriedType,carriedCount).UnitSystem, the oldWanderSystem): pick a kind, walk, work (water deposits from the shore), take what the deposit, the trip and the carry limit allow, haul home, deposit. Config:units.carryCapacity,searchRadiusand a per-resourcegathertable.World.drainStockChanges(),ticked.stock,applyStockChanges; halls and unit state/carried resource in the protocol; working poses and carried bundles in the sprite layer.spacingper resource rule (best tiles first, skipping any too close to one of the same kind) and lower default shares. Guards now check objects are grouped and that spaced ones never touch.determinism.mdVersion 6,save-format.mdversion 7,terrain.md, roadmap, development; newe2e:gather.Why the goldens moved (twice, each in its own commit)
Hash 6 hashes nodes instead of six layers, plus new columns and stockpiles, and villagers now gather, which moves stocks and nation profiles (
8766aa8); then sparse placement changes every world's resources (324173f). Python reference vectors were recomputed for the newwriteUint32Array. All 22 golden values and their save round trips match on Node 22, Chromium 157 and QuickJS after each.Verification
pnpm typecheck,pnpm lint,prettier --check,pnpm test(all packages) andtest:determinismpass.NodeStore,NodeIndex,Stockpiles, the gather cycle, validate rules, placement spacing and the delta code; survivors were equivalent or got a test.e2e:gatherande2e:unitspass; screenshots checked by eye (villagers working, carrying, deposits drawn down).Limits (honest)
Type of Change
Checklist
pnpm build)pnpm lint)pnpm typecheck)pnpm test; andpnpm test:determinismsince the engine changed)Generated by Claude Code