Split The code is public; the app answers only to the crew.
`bun run scripts/cost.ts`: what a tick of the simulation costs, and a guard so it stays that way #118
Check · Review · Land · Live done — Landed and live in production.
scripts/cost.ts answers what one tick of the simulation costs, in the shape measure.ts already set: it steps a seeded ten-player world through the shipped world.update with NOINPUT, warms up 256 ticks, then records each tick's wall clock into a Float64Array and prints ticks sampled, mean, p50, p95, p99, max, the ticks-…
shipped merged
Sign in to join this conversation.
new above
offline
scripts/cost.tsanswers what one tick of the simulation costs, in the shapemeasure.tsalready set: it steps a seeded ten-player world through the shippedworld.updatewithNO_INPUT, warms up 256 ticks, then records each tick's wall clock into aFloat64Arrayand prints ticks sampled, mean, p50, p95, p99, max, the ticks-per-second the mean implies, and the share of the 15.6 ms a 64 Hz tick is allowed. Flags are--ticks,--seed,--rules,--difficulty, parsed exactly the waymeasure.tsparses its own — missing or malformed keeps the default — withparseArgsexported and tested. One world exists at a time; a match that ends is replaced outside the timed region so a long sample measures play rather than a scoreboard.The arithmetic is
summarize, a pure function over a list of milliseconds with nearest-rank percentiles and no clock anywhere in its tests — checked on a shuffled 1..100 (p50 50, p95 95, p99 99), on a single value, on the empty list, and on aFloat64Arraygiving the same answer as the plain array. Exactly one assertion in the suite depends on how fast the machine is: 600 sampled ticks must average under 2 ms, roughly fourteen times the measured cost, so a real regression inbots.ts,trace.tsorworld.tsfails and a loaded CI box does not. That test runs in about 0.2 s.Measured here over three runs of the defaults: mean 0.14 ms a tick, p50 0.11, p95 0.29, p99 0.43 — about 7,200 ticks a second, 1% of the tick budget. The one number I did not put weight on is
max, which swung between 3 ms and 30 ms run to run; that is the collector and the box, so the README says to read the mean and the percentiles and ignore it rather than pretending it is stable.README.mdcarries the numbers and the command next to themeasure.tssection, and in the command list up top. Nothing undersrc/changed;bun testis green at 458 tests.To try it:
bun run scripts/cost.ts, thenbun run scripts/cost.ts --ticks 30000 --rules long --difficulty hardfor a longer, harder sample.🤖 Generated with Claude Code
Closes #90