# Prime Gap Atlas: 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.

## Prime gap travel

Travel along sixteen consecutive actual primes, visiting outposts at positions 4, 9 and 15. Each jump spans at most three prime landmarks and cannot skip an outpost. Supply cost is the ceiling of the numeric gap divided by four, with a ruler-timed headwind surcharge. Rest replenishes six supplies, up to sixteen.

A four-step reference continuation uses the same 0.82 discount and 0.12 move cost. Utility rewards position by 9, stamps by 35, a win by 60, reserves by 0.2 or 1, and visited landmarks by 0.2 or 5 depending on priority. Safe-prime and twin-prime flags are visible model inputs, not model predictions.

Inputs, in order: `travelling, distance in primes, numeric gap, supply cost, supplies left, outpost arrival, next outpost distance, primes visited, current index, ruler pulse, scenic priority, supply priority, headwind, twin destination, safe-prime destination`.

## 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 **3,078 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 | 9.44 | — |
| Selected model | 64/64 | 9.12 | — |
| Selected, changing nudges | 32/32 | 9.16 | — |
| Reference strategy | 64/64 | 10.12 | — |
| Random legal moves | 64/64 | 13.38 | — |

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: **13.467876**; R²: **0.394551**. These measure the designed target, not winning probability. **71,511 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 prime-gap-atlas
/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)
