Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

All notable changes to Econ-Engine are documented here. The changelog records what changed in each update. Design rationale, experiments, observations, and lessons are documented separately in [Lab Notes](LAB_NOTES.md).

## [LIFE15-Lighter-070] - (2026-10-28)

- An exchange no longer copies group members who are dead or out of talking distance, and copies back only the views that changed.
- Looking around scans nearby chunks directly, without candidate lists; only walkers have their position worked out from their route.
- The chunks a route crosses are found with one reused buffer instead of temporary lists.
- The wake-up queue cancels lazily: cancelled entries are marked and dropped at the front, or all at once when they outnumber the rest.
- New `advanceValley` runs the engine on a state in place; the worker uses it, and `stepValley` stays pure. The view copy snapshots the followed person's memory itself.
- The daily summary counts known places without copying them.
- Days 50 to 59 at 1 month/s run about 27% faster. Every fingerprint stays the same.
- New tests: advancing in place equals stepping copies, and view copies of an in-place run equal those of a pure run.
- The Life 15 specification is revised for update 070, with the hut-building week's cost left as a question for later.

## [LIFE15-Worker-069] - (2026-10-28)

- The Life engine runs in a Web Worker. The page keeps the clock and asks the worker for a goal 0.1 s ahead at the speed shown; the worker runs in slices of at most 50 ms and sends a view copy every stride minutes (the speed over 60, at least one).
Expand Down
12 changes: 12 additions & 0 deletions LAB_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@

Every meaningful model, architecture, experimental, or design update should receive a newest-first entry. Use at most one base update number per Git commit. Refinements completed before that commit keep the same base number with a decimal suffix—for example, `003` and `003.1` belong to the same commit family. Allocate the next base number only for a later commit. Preserve the context, observed problem or research question, rationale, important implementation decisions, trade-offs, findings, and unresolved questions. Distinguish verified observations from hypotheses. If the original rationale is unknown, say so rather than inferring intent from the finished code.

## [LIFE15-Lighter-070] - (2026-10-28)

The owner asked why 1 month/s (30 simulated days a second) is out of reach and approved any speed-up that leaves the simulation unchanged. The camp wake-up cascade was kept on purpose: who wakes whom will matter for relationships.

**Where the time went, measured in Node on the canonical forty, seed 20260813, 12-hour steps on main.** Days 1–10: 100–200 ms a simulated day. Days 11–17, the hut-building week: 0.5–3.3 s. Days 20–90: 170–650 ms, typically about 250 ms. Days 50–60 averaged 228 ms: 1,008 wake-ups a day ending in "keep resting" at 37 µs each (37 ms; looking around 11, choosing a task 7.5, the exchange check 6, the body 6, meetings 3.7), and 403 walk decisions at 345 µs each (139 ms; route planning 68, arrival wake-ups 20, choosing water 18, leisure walks 14). About 274 MB was allocated a day, and garbage collection took about 46 ms.

**What was built.** Six speed-ups that change no result: the exchange check skips absent members, looking around and route crossings stop building temporary lists, the queue cancels lazily, the worker advances its state in place with `advanceValley`, and the daily summary counts places without copying. Every fingerprint passed unchanged.

**After.** Pure 12-hour steps take about 170–180 ms a day past day 50, with garbage collection about 29 ms. Run as the worker runs (50 ms slices, 720-minute strides, a view copy and its changes each step), days 50–59 took 200, 172 and 177 ms a day in three runs against main's 275, 240 and 236: about 27% faster, roughly 4.2 to 5.7 days a second of engine time. Not checked in the browser this time: the preview pane was hidden, so the browser figures of update 069 stand.

**Findings.** Keeping still is no longer the main cost. Walk decisions are now about 60% of a day, and the hut-building week is still about ten times slower than later days. 1 month/s would need each day near 33 ms, about five times faster again, so the next work is on route planning and water choice, then the hut week.

## [LIFE15-Worker-069] - (2026-10-28)

After update 068 the page still ran the engine on its own thread, so every slow stretch of the engine was a slow frame: at 1 month/s the page drew about 16–19 frames a second. The owner asked for the engine in a worker thread and approved the revised specification.
Expand Down
4 changes: 2 additions & 2 deletions docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ The 3D world draws each firm and Government across its plot: `buildingScale` str

## Life 15: habitual routes, bodies, clock and ground mesh

`src/valley/` is the independent Life core described by [LIFE15_SPEC.md](LIFE15_SPEC.md). It imports only the pure RNG helpers from the frozen MVP9 core. Quantities are integers: centimetres, kilocalories, kilograms, millilitres and minutes. `stepValley(state, toMinute)` is pure and deterministic: it clones the state, runs every queued wake-up up to `toMinute` and sets the clock there.
`src/valley/` is the independent Life core described by [LIFE15_SPEC.md](LIFE15_SPEC.md). It imports only the pure RNG helpers from the frozen MVP9 core. Quantities are integers: centimetres, kilocalories, kilograms, millilitres and minutes. `stepValley(state, toMinute)` is pure and deterministic: it clones the state, runs every queued wake-up up to `toMinute` and sets the clock there. `advanceValley(state, toMinute)` runs the same loop on the state itself, for a caller that owns it: only the worker does.

- **Bodies and personality.** `nature.ts` draws bounded integer normals and applies integer Cholesky factors to body and Big Five correlations. `layout.ts` owns isolated body and traits streams; founder positions, skills and craft draws are unchanged. Each person stores immutable body measurements, trait scores, derived thresholds, load and rates. `personConfig` supplies a cached personal view to shared body, route and task helpers; run settings stay separate. Founder means and spreads by sex are recorded once, in thousandths. State copies copy the small body/trait records independently.
- **Clock and queue.** `clock.ts` holds the wake-up queue, ordered by minute, then world before people, then person id. `calendar.ts` turns a minute into a day, a season and a year of `daysPerYear` days. `world.ts` owns hourly and midnight work: regrowth, fish growth, fires and daily summaries. `wake.ts` handles a person's wake-up: it settles the task that ended, perceives, chooses the next task by priority and queues the next wake-up.
Expand All @@ -98,7 +98,7 @@ The 3D world draws each firm and Government across its plot: `buildingScale` str

The page opens on `LifePage.tsx`, which shows the settings screen (`RunSettingsScreen.tsx`) until Start and then a `ValleyApp` for the run it built. `runSettings.ts` is pure: it turns the five run settings into a configuration, scaling the counts of places and landforms with the world's area, and returns the first thing wrong with them. A running `ValleyApp` never changes its settings; New run returns to the settings screen. `LifePage` keeps the loading card up until `ValleyApp` calls `onReady`, after the 3D view has drawn its first frame or failed to start.

The engine runs in a Web Worker, `engineWorker.ts`; `engineLink.ts` is the page's end of it. Both threads build the valley with the pure `createValley`, so the layout never crosses between them. The page keeps the clock and each frame asks the worker for a goal minute 0.1 s ahead at the speed shown; the worker runs towards it in slices of at most 50 ms and sends a view copy every stride (the speed over 60 minutes, at least one) and at the end of each slice. `viewCopy.ts` makes the view copy: only the routes of walks under way, each person's next wake-up in place of the queue, exchanges and walk records among the events, and current memory only for the followed person. A copy travels as its changes from the last copy sent (`changeOf`, `applyChange`), so parts the engine shared or recopied unchanged are not sent and keep their identity on the page.
The engine runs in a Web Worker, `engineWorker.ts`; `engineLink.ts` is the page's end of it. Both threads build the valley with the pure `createValley`, so the layout never crosses between them. The page keeps the clock and each frame asks the worker for a goal minute 0.1 s ahead at the speed shown; the worker runs towards it in slices of at most 50 ms and sends a view copy every stride (the speed over 60 minutes, at least one) and at the end of each slice. The worker owns its state, so it advances it in place with `advanceValley`. `viewCopy.ts` makes the view copy, with its own snapshot of the followed person's memory: only the routes of walks under way, each person's next wake-up in place of the queue, exchanges and walk records among the events, and current memory only for the followed person. A copy travels as its changes from the last copy sent (`changeOf`, `applyChange`), so parts the engine shared or recopied unchanged are not sent and keep their identity on the page.

The observer, `src/valleyView/`, keeps the copies received and a continuous displayed minute (`advancePlayback` in `valleyViewModel.ts`). It draws the newest state at or before the clock, at a minute less than one minute after it, so every wake-up up to the drawn minute has run and none after it, and each person is drawn from the task actually under way: position from `positionAt`, a gesture from the task's kind, energy from `energyAt`. When the worker is behind, the clock waits within the newest state's minute, so a slow day stops the clock and not the page. Step shows the next minute once it arrives; a change of speed jumps to the newest copy. Below a day per second people walk continuously. From a day per second up, people are hidden and the valley is drawn as a map of stocks, groups and huts. Plants and ground are drawn in 500 m tiles near the camera, and the followed forager's overlays are redrawn at most every 250 ms; each place's ring is draped on the ground once, since places and their radii never move. The panels refresh ten times a second, or twice a second at map speeds, and the history charts are drawn again only when a day ends, the followed forager changes or a run starts. Thickets, stands and outcrops are drawn as decoration: a fixed number of bushes, hazels, trees or rocks per place, sharing out the place's stock in turn, so what is drawn stays in proportion to what is there. The decoration uses no simulation stream.

Expand Down
Loading
Loading