Skip to content

feat(examples): a complete optimization method for a game - #39

Merged
drewstone merged 1 commit into
mainfrom
feat/optimization-method
Aug 27, 2026
Merged

feat(examples): a complete optimization method for a game#39
drewstone merged 1 commit into
mainfrom
feat/optimization-method

Conversation

@drewstone

Copy link
Copy Markdown
Contributor

compareOptimizationMethods takes methods, not loops. It runs each on disjoint train, selection and final-test scenarios and reports every method's lift over the baseline with a simultaneous, Bonferroni-adjusted bootstrap interval. The question it answers is whether one way of searching beats another by more than the game's own noise.

bestOfN is the simplest honest method: author N candidate programs, score each on the selection partition, keep the best. The final-test partition is never read — choosing a winner on test data reports a lift it did not earn, and it is why the comparator hands a method two partitions instead of one.

Cost is stated, not assumed

CostProvenance is a union that structurally refuses to call a partial sum observed. One candidate that billed a plan and reported no per-request figure makes the whole total {kind: 'uncaptured', usd: null}, with the reason recorded. Summing it as zero would make the arm nobody could meter the cheapest one.

That is the same rule this repo enforces on a cell's usd, now enforced by a type rather than by discipline.

What running the framework's own statistics revealed

Re-running the earlier three-profile 2048 study through pairedBootstrap:

contrastintervalverdict
opus vs sonnet[-40, 300]includes 0
opus vs haiku[60, 340]excludes 0
sonnet vs haiku[40, 212]excludes 0

All three returned gateEligible: false.BOOTSTRAP_GATE_MIN_N is 20, and every study in this repo so far has run 1 to 3 replicates. The framework declines to let them gate a decision, which is the correct answer.

One methodological note for whoever uses this next: pairedBootstrap pairs by index. The replicates here are not matched — sonnet rep1 and haiku rep1 share nothing but a subscript — so pairing them manufactures precision. That is why its sonnet-vs-haiku interval excludes zero while an unpaired resample of the same numbers does not. Use seedGroup to make replicates genuinely paired before relying on it.

Local: 0 typecheck errors, boundary check passes.

`compareOptimizationMethods` takes methods, not loops. It runs each on disjoint
train, selection and final-test scenarios and reports every one's lift over the
baseline with a simultaneous, Bonferroni-adjusted bootstrap interval, so the
question it answers is whether one way of SEARCHING beats another by more than
the game's own noise.
`bestOfN` is the simplest honest method. It authors N candidate programs,
scores each on the selection partition, and keeps the best. The final-test
partition is never read, which is the one rule a method may not break: choosing
a winner on the test data reports a lift it did not earn.
Spend is stated through `CostProvenance`, which is a union that refuses to call
a partial sum observed. One candidate that billed a plan and reported no
per-request figure makes the whole total `{kind: 'uncaptured', usd: null}` with
the reason recorded, rather than summing it as zero and making the arm nobody
could meter the cheapest one.
Authoring a candidate is supplied by the caller, because building a player is
the expensive half that carries credentials, and a method should not decide how
an agent is run.
@drewstone
drewstone merged commit 661d585 into mainAug 27, 2026
11 of 12 checks passed
@drewstone
drewstone deleted the feat/optimization-method branch August 27, 2026 19:20
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@drewstone