# Index Isles: 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.

## Square-coded navigation

Thirty-six islands occupy square shells. For index n, k=floor(√n) and r=n−k²: use (r,k) when r<k, otherwise (k,2k−r). Actual pytoolz Indexer data supplies address codes n² XOR mask, with masks 5, 10 or 30. Three parcel destinations come from a colex-ranked three-subset of eight beacons; a fourth is seeded separately. Adjacent rowing costs one, straight two-cell glides cost two plus any ruler-current surcharge; docking replenishes six supplies up to ten.

The action target rewards distance improvement by 5 and delivery by 35, penalizes supply use by 0.15 or 1 and revisits by 1 or 4, and values resting at +6 below three supplies or −4 otherwise. The model receives decoded locations and learns navigation preferences. Square roots, XOR, indexing and decoding are explicit verified mathematics, not learned integer algorithms.

Inputs, in order: `rowing, distance before, distance after, distance gained, delivery, next letter distance, supplies after, steps, destination visits, letters delivered, supply priority, fresh route priority, current pulse, currents`.

## 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 **9,189 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 | 11.30 | — |
| Selected model | 64/64 | 11.31 | — |
| Selected, changing nudges | 32/32 | 10.84 | — |
| Reference strategy | 64/64 | 11.30 | — |
| Random legal moves | 7/64 | 87.58 | — |

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.002111**; R²: **0.999999**. These measure the designed target, not winning probability. **13,119 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 index-isles
/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)
