# Polyrhythm Postcards: 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.

## Loop arrangement

Rotate three loops of lengths 3, 4 and 6 across twelve beats. Record four arrangements, allowing at most six edits before each recording. The alternate condition rotates target accents by one beat. The browser plays separate bell, string-like pluck and low pulse voices.

A target accent earns 3 if played and costs 2 if missed. An off-accent hit costs 0.5; an off-accent rest earns 1. Collisions cost 1 per extra voice, or 2 for the space priority. Density earns 0.3 per hit for lively priority and costs 0.1 otherwise. A rotation’s target is three times its fit improvement minus 0.75; recording has target 0. Recording quality accumulates fit, so higher is better on this designed objective. It is not a human listening score. Any legal policy records all four arrangements before the turn limit.

Inputs, in order: `recording, fit before, fit after, fit change, track period, new offset, notes on track, edits this postcard, postcards made, lively priority, space priority, shifted accents`.

## 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: **early**, with **7,788 action rows** and **16 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 | 8.03 | 30.84 |
| Selected model | 64/64 | 8.03 | 30.84 |
| Selected, changing nudges | 32/32 | 7.94 | 37.52 |
| Reference strategy | 64/64 | 8.09 | 30.97 |
| Random legal moves | 64/64 | 20.48 | 11.27 |

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.029492**; R²: **0.999816**. These measure the designed target, not winning probability. **4,707 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 polyrhythm-postcards
/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)
