Repository navigation
M1: units you can see (entities, walking villagers, zoom-gated pixel sprites) - #39
Merged
CodeByBryant merged 9 commits intoNov 24, 2026
Conversation
Struct-of-arrays (kind, tile, owner, state, home, target, wake, leg start and end). The lowest free id is always the next one handed out, whatever order rows were freed in, so allocation depends only on which rows are alive and a restored world allocates as the original would. Rows are visited in id order. EntityKind in contracts. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cn5qp59UwGNst3umuaQf6u
…between walkers Pathfinder is A* over 8 neighbours on the deterministic heap; a step costs the mean of the two cells so a route costs the same either way and its reverse is exact. RouteCache keeps each route found for the way there and the way back (a memo only: a route is a pure function of the grid). routePosition says where a walker is part of the way along, by cost. Checked against a plain Dijkstra on random grids as well as drawn ones, and mutation checked. A probe measured pathfinding as the whole cost of a crowd, which is why routes are shared. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cn5qp59UwGNst3umuaQf6u
…rld (hash 5, save 6) Villagers are entity rows that walk shared A* routes between settlements; a timer wheel wakes them, positions are derived lazily from route and leg progress, and arrival lands on a per-cell land anchor tile. Entities are hashed (schema 5) and saved (format 6); derived state is rebuilt. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cn5qp59UwGNst3umuaQf6u
Every world now carries villagers, so every golden hash changes; the depletion golden too. The ten entries cover walking units (192 villagers, 191 moved after 100 ticks on the small world). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cn5qp59UwGNst3umuaQf6u
22 resources in three states (full, low, empty), a tintable villager with two walking frames, a banner, house, hall and 16 road pieces that join by mask. Packed into one RGBA atlas with a frame table; pure (no DOM, no PixiJS) and pinned by checksum so the art cannot drift unseen. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cn5qp59UwGNst3umuaQf6u
…nit interpolator Pure and tested (with mutation checks): which tiles the camera sees, when sprites replace overlays, a road byte per tile from the route network that joins neighbours by side, and a main-thread interpolator that glides units between world snapshots without a map (merge by id). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cn5qp59UwGNst3umuaQf6u
…ted sprites The world sends unit positions with every run and a road byte per tile once; the renderer pools sprites for the visible tiles only (resources from the slot arrays, roads from the route network, a hall and banner at each capital, tinted villagers glided between snapshots). Sprites appear when a tile is 10 screen pixels wide. The canvas publishes sprite counts as data attributes for tests. IndexedDB version 7 for save format 6; adds the units e2e. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cn5qp59UwGNst3umuaQf6u
The overlays are added after the sprite container, so they covered it; the container now sorts on top. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cn5qp59UwGNst3umuaQf6u
…cts inset so neighbours do not touch Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cn5qp59UwGNst3umuaQf6u
9 tasks done
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 M1 of the units plan (ADR 0008). Stacked on #38 (M0): the base is the M0 branch, so this diff is M1 only. Retarget to
mainonce #38 merges.The world now has simulated villagers that walk, and you can see them: zoom in and resource objects, roads, a hall at each capital and tinted villagers are drawn as pixel sprites. They only wander so far; gathering, building and settling are M2 onward.
Changes
EntityStore(struct-of-arrays, lowest-free-id allocation, saved and hashed), A*Pathfinderand a sharedRouteCacheover the 4-tile cost grid, counter-based randomness for unit behaviour, and a timer-wheelWanderSystem(event-driven, positions derived lazily from route and leg progress, arrival on a per-cell land anchor tile).unitPositions()snapshot; hash schema 5, save format 6, web IndexedDB version 7. Config gained aunitssection.UnitInterpolator, and pooledSpriteLayers(visible tiles only).tickedmessage and a road byte per tile withready; the canvas publishes sprite counts as data attributes; newe2e:units.Why the goldens moved
Every world now carries villagers, so every golden hash changes (hash schema 4 to 5). They are regenerated in their own commit (
2e371c5). The vectors were recomputed with the independent Python reference, and all 20 golden values (and their save round trips) match on Node 22, Chromium 157 and QuickJS.Verification
pnpm typecheck,pnpm lint,prettier --check,pnpm test(all packages) andtest:determinismpass.e2e:unitspasses and the screenshots were checked by eye: sprites off when zoomed out, on when zoomed in, villagers move while time runs.Limits
Type of Change
Checklist
pnpm build)pnpm lint)pnpm typecheck)pnpm test; andpnpm test:determinismsince the engine changed)Generated by Claude Code