# Measured runs on scriptbots.org

The Results chapter of https://scriptbots.org/ is drawn from the files in this folder. They come
from the serial WebAssembly build that site release `01d9eb4fed0e6b206b7290018a2282c166aac7e2`
served (SHA-256 `6774a652bb197c72d5401b3ef9be6d3c00f377a5dafa28c4c49065be89551bc9`), run under
Node 26.8.1 on an Apple M5 Ultra. Each run is single-threaded and one run per seed was made, so
the numbers describe these runs. They are not averages and carry no intervals.

## Files

- `measure.mjs` runs one scenario and seed and writes a trajectory: every `<every>` ticks, the
  living count, cumulative births and deaths, mean energy and health, the Observatory's three
  diet groups, the count per brain family, the deepest and mean generation, and the mean wall
  time of the ticks since the last sample.
- `determinism.mjs` runs Timed Meadow (`meadow`) from seed 42 twice and from seed 43 once, and
  hashes each `worldCheckpoint()` with SHA-256. It also reports each declared Timed Meadow
  seed's population at tick 360, the horizon of that scenario's envelope.
- `charts.py` turns the data into the page's SVG figures. `web/build-site.sh` calls it during
  every site build and places each figure at its `<!-- chart: name -->` marker in
  `web/index.html`. Its `parameters()` draws the rules chapter's settings table (04.7).
- `defaults.mjs` prints `default_config()` of a serial build as JSON. The site build runs it on
  the Wasm it packages and hands the result to `parameters()` with the three browser scenarios'
  settings, so the table's defaults come from the shipped code. The build fails if a listed
  setting no longer exists or a browser scenario changes a setting the table leaves out.
- `data/` holds the outputs: `em-<seed>.json` for 50,000 ticks of Evolution Meadow sampled
  every 250, `meadow-<seed>.json` for 1,500 ticks of Timed Meadow sampled every 25,
  `ffm-<seed>.json` for 10,000 ticks of Food-funded Meadow sampled every 100, and
  `determinism.json`.

## Reproduce

Both scripts configure the world the way the page's worker does: the Rust defaults, then the
scenario's settings, then `locomotion_model: "solid"`, with 64 founders and the mixed brain roster.

Each release is served under its own `/releases/<site>/` path, and a deploy replaces the previous
release's files. Fetch the current release named in `/build.json` and check the Wasm hash. If it
differs from the one above, the site has moved to a newer simulation build and its numbers may
differ from these.

```sh
site=$(curl -fsS https://scriptbots.org/build.json | python3 -c 'import json, sys; print(json.load(sys.stdin)["site"])')
mkdir -p assets/wasm
curl -fsS -o assets/meadow.mjs "https://scriptbots.org/releases/$site/assets/meadow.mjs"
curl -fsS -o assets/wasm/scriptbots_web.js "https://scriptbots.org/releases/$site/assets/wasm/scriptbots_web.js"
curl -fsS -o assets/wasm/scriptbots_web_bg.wasm "https://scriptbots.org/releases/$site/assets/wasm/scriptbots_web_bg.wasm"
shasum -a 256 assets/wasm/scriptbots_web_bg.wasm   # 6774a652…51bc9

node measure.mjs "$PWD/assets" evolution_meadow_v1 42 50000 250 em-42.json
node measure.mjs "$PWD/assets" meadow 42 1500 25 meadow-42.json
node measure.mjs "$PWD/assets" food_funded_meadow_v1 11 10000 100 ffm-11.json
node determinism.mjs "$PWD/assets" 600 > determinism.json
python3 charts.py data charts/
```

The assets directory must be an absolute path, because the scripts import from it. Repeat
`measure.mjs` for Evolution Meadow seeds 137 and 11, Timed Meadow seeds 137 and 20260717, and
Food-funded Meadow seeds 42 and 137. The `msPerTick` column depends on the machine and on what
else it runs; every other number in `rows` should match exactly, since the simulation is
deterministic. The Evolution and Food-funded runs and `determinism.mjs` ran side by side; the
Timed Meadow runs, whose timings the cost figure uses, ran one at a time afterwards.

In the committed files, the local `assets` path the scripts record was replaced with the public
release URL the runs used, and `site` names that release; `determinism.json` also records the
machine, the configuration and the envelope from `scenarios/meadow.scenario.toml`.

Births and deaths are summed from each tick's `snapshot().summary`. Arrivals, whether scheduled or
keeping a population floor, are not counted as births, so an open world's population can exceed
64 + births − deaths by the number of arrivals. Evolution Meadow adds one arrival every 100 ticks
and tops the population up to 64.
