# Chord Quilt: pytoolz/WSRF training

A real **`pytoolz.wsrf.WSRFRegressor`** ranks the legal moves. Training happens in Python; the browser evaluates the complete exported regression forest. It does not retrain during play. This is supervised action-value learning from explicit game objectives.

## Melody harmonization

Choose among C, Dm, Em, F, G and Am under four three-note bars. Finish three songs. All chord placements are legal, and filled bars stay in place until that song is recorded. The alternate condition changes playback tempo only.

A matching melody pitch earns 3; a mismatch costs 1. Warm priority gives F and Am 2 extra points. The final bar earns 5 for C, or G under bright-ending priority. Adjacent chords earn 1.5 per shared note and lose 0.25 per semitone of circular root distance. Each action target is its immediate change in fit. Recorded songs accumulate fit. All policies finish in twelve moves; the quality comparison measures this explicit harmony objective, not a claim of musical taste.

Inputs, in order: `melody matches, melody misses, previous shared notes, next shared notes, previous root distance, next root distance, ending chord, home chord, bright chord, warm chord, bar position, empty bars, warm priority, bright priority`.

## Training and candidate selection

`pt.indexrng.Index("curiosity-eight-v1", backend="blake2b")` generates separate train, recovery, validation, test and guided streams per game. Actual qrand arithmetic, through the existing checked browser adapter, determines seeded world details and exploration. The first fit uses 96 reference episodes, with a random legal move every eleventh turn. Initial priorities vary only in train/recovery streams. Both conditions are sampled by seed.

The early forest uses 8 trees per zone and depth 10. Another 24 guided episodes from that model supply recovery examples; all legal actions at visited states receive fresh targets. The second fit uses 24 trees per zone and depth 16. Both use minimum leaf size 2, all features, seed 2026, one worker, no adaptive complexity, no zone prior and no calibration. Zones are `calm` and `challenge`, corresponding to the two conditions, including cosmetic conditions in the number/patch/chord games.

Both candidates play the same 24 validation seeds. Selection compares completions, then arrangement quality (or game score), then fewer turns. Selected: **final**, with **21,600 action rows** and **48 trees**. Training/test seeds are disjoint. Test results are measured only after selection and are not used for fitting or selection.

The number games each have separate pools of 96 training, 24 validation, 64 test and 32 public-play puzzles. Their givens were removed only when the deduction engine could still finish; an independent backtracking test verifies each of the 432 puzzles has exactly one solution. Guided puzzle evaluation uses the test pool with different seeded conditions. These are finite curated pools, not unlimited generated Sudoku.

## Recorded evaluation

| Policy | Completed | Mean moves | Mean arrangement score |
| --- | --- | --- | --- |
| Early model | 64/64 | 12.00 | 104.16 |
| Selected model | 64/64 | 12.00 | 104.21 |
| Selected, changing nudges | 32/32 | 12.00 | 102.70 |
| Reference strategy | 64/64 | 12.00 | 104.49 |
| Random legal moves | 64/64 | 12.00 | 39.08 |

The solo policies use identical 64 test seeds, balanced priority and a seeded condition. The guided policy uses 32 separate seeds and changes focus and conditions every five turns. Guided and solo means are not same-seed causal comparisons. Shorter games can also be losses, especially in square packing. Tests here are small deterministic samples, not guarantees of perfect play.

Held-out action-value MAE: **0.021049**; R²: **0.997421**. These measure the designed target, not winning probability. **51,249 Python/JavaScript predictions** agree within `1e-9`, with observed maximum error `0`. Fixtures contain held-out visited features and float32 neighbors around every selected tree threshold.

The optional brain panel shows actual inputs, scores, tree paths and tree standard deviation. It compares the early/current model and nudged/un-nudged choices, and previews one legal move on a copy. Inspection does not advance the game. Decisions can be replayed, undone, downloaded and branched.

## Reproduce and inspect

```sh
/home/wiliamrocha/.spenv/bin/python -B tools/curiosity/prepare.py
/home/wiliamrocha/.spenv/bin/python -B tools/curiosity/train.py --game chord-quilt
/home/wiliamrocha/.spenv/bin/python -B tools/curiosity/document.py
node tools/test-curiosity.cjs
npm run build
```

Run from the arcade root with the recorded local pytoolz/WSRF environment. The full eight-game reproduction uses `--game all`. Preparing the data requires Node and Python/NumPy/pytoolz. Raw solution drafts and temporary training rows are excluded from the public folder.

[Evaluation, seeds, versions and source hashes](training/report.json) · [Compressed Python predictions](training/validation.json.gz) · [Decoded checksum](training/fixture-package.json) · [Actual math-library provenance](../../tools/curiosity/math-report.json) · [Additional library paths](../../tools/curiosity/library-sources.json) · [Training code](../../tools/curiosity/train.py) · [World rules](model.js)
