rp_typecol gains on pawn (+0.085), knight (+0.010) and bishop (+0.015) and loses on rook (-0.022), queen (-0.015) and king (-0.010). The owner named that split in advance from chess, not from the data. A capacity story predicts a uniform gain and the sign flip rules it out: twelve kernels halve the data behind each, which pays only where colour changes the law. First arm to exceed the rule-knowing control in aggregate, 0.8353 against 0.8305 -- by a different route than rp, which beats it on rook, queen and king where typecol does not.
139 lines
7.4 KiB
Markdown
139 lines
7.4 KiB
Markdown
# Teaching the movement rules, on generated positions
|
|
|
|
The organism was never taught how the pieces move. Every memory result before this file was
|
|
measured on top of that gap. This is the base.
|
|
|
|
**Where it stands: the RP learns the rules from a generated curriculum and, on the pieces where
|
|
reading the board matters most, exceeds a control that knows the rules and cannot see.**
|
|
|
|
## Why not games
|
|
|
|
Two failures of games as a curriculum, both measured rather than argued:
|
|
|
|
- **Coverage.** A rook or queen is blocked in 98-100% of real positions (`chess_shape.json`), so
|
|
the model learned the geometry it saw instead of the rule behind it — it scored *worse* in
|
|
open positions (rook 0.811) than blocked ones (0.891). Here the piece count is sampled
|
|
uniformly from 2 to 32, so a near-empty board is as common as a crowded one, and every piece
|
|
type visits all its legal squares: measured at 3000 positions, a knight lands on each of the
|
|
64 squares between 65 and 107 times.
|
|
- **The target left out three rules entirely.** The reachability task asked for
|
|
`board.attacks`, which for a pawn on e2 returns d3 and f3 while its moves are e3 and e4 —
|
|
**no overlap at all**. Castling never appeared (a king's attack set is its five adjacent
|
|
squares; c1 and g1 are not in it) and neither did en passant. The model did not fail to learn
|
|
these. It was never asked. The target here is `generate_pseudo_legal_moves`.
|
|
|
|
## Setup
|
|
|
|
300 000 generated positions streamed for training (never stored: dense targets would be 6 GB),
|
|
4 000 held out from a disjoint seed. Target: every piece's pseudo-legal destinations, as a
|
|
multi-hot over the 15x15 grid of relative offsets. Metric: precision@k per piece, k the true
|
|
number of destinations. 4 seeds. No memory anywhere in this file — this is the RP question
|
|
alone, per the sequencing policy in `AGENTS.md`.
|
|
|
|
**`shape` is the control**: it knows each piece's type, its movement rule and its own flags, and
|
|
reads *nothing else on the board*. It proposes the un-blocked ray. Beating it is what "reads the
|
|
occupancy" means, and it is the bar this file is measured against — not 1.0.
|
|
|
|
Castling rights and the en-passant square are handed over as per-entity attributes. They are
|
|
**state, not position** — a rook must remember whether it has moved — and without them the same
|
|
board has two different correct answers. Removing them is the cleanest memory experiment this
|
|
project has available, with exact ground truth instead of a 0.03 correlation, and it belongs to
|
|
the parked GRP line.
|
|
|
|
## Results
|
|
|
|
```
|
|
arm prec@k pawn knight bishop rook queen king
|
|
constant 0.4075 0.4491 0.0000 0.1730 0.4947 0.5609 0.7781
|
|
rp_type 0.7793 0.6573 0.8574 0.7856 0.7569 0.7510 0.9124
|
|
rp 0.8161 0.7835 0.8481 0.7748 0.7837 0.7680 0.9227
|
|
shape 0.8305 0.8156 0.8624 0.8299 0.7679 0.7618 0.9134
|
|
|
|
random ranking scores 0.0233
|
|
```
|
|
|
|
**The RP exceeds the rule-knower on rook (+0.016), queen (+0.006) and king (+0.009)** — the
|
|
pieces whose moves are cut by occupancy, where ignoring the board costs most. It remains below
|
|
on pawn (-0.032), bishop (-0.055) and knight (-0.014).
|
|
|
|
Absolute position, added as attributes, is worth +0.020 and closes the gap to `shape` from
|
|
0.034 to 0.014:
|
|
|
|
```
|
|
without position with position
|
|
rp 0.7962 0.8161
|
|
rp_type 0.7583 0.7793
|
|
shape (was always given it) 0.8305 0.8305
|
|
```
|
|
|
|
The CPPN sees only `r_ij`, which makes the representation translation-invariant, and a chess
|
|
board has edges: a knight has 2.96 destinations on the rim against 6.85 in the middle, and 43%
|
|
of knights sit on the rim. `shape` was handed the square all along, so the comparison had been
|
|
biased *against* the organism.
|
|
|
|
**A prediction that did not verify.** The improvement was predicted to concentrate on rim
|
|
pieces. Per type it is roughly flat — pawn +0.008, knight +0.016, bishop +0.028, rook +0.028,
|
|
queen +0.029, king +0.022 — and the knight, 43% of which sit on the rim, gained *less* than the
|
|
queen. The per-type cut cannot settle a per-square hypothesis, so this is recorded as
|
|
unverified rather than as either confirmed or refuted. Position pays; the mechanism proposed
|
|
for why it pays is not demonstrated.
|
|
|
|
## Type in the kernel reverses sign with coverage
|
|
|
|
On game data, putting the piece type into `e_ij` was worth +0.10 and took the knight's L from
|
|
exactly zero to 0.758 (`chess_reach.md`). On the generated curriculum `rp_type` lands *below*
|
|
`rp`, and the whole deficit is the pawn: 0.6573 against 0.7835, with knight and bishop still
|
|
slightly ahead. That earlier jump was in part a crutch against scarce data.
|
|
|
|
The likely cause is specific and testable: `e_ij` carries the piece **type** and not its
|
|
**colour**, so a white pawn and a black pawn share one kernel while their moves are mirrored.
|
|
`own_rank` — rank counted from the piece's own back rank — is present in this run and did not
|
|
fix it on its own, which points at the colour rather than the orientation.
|
|
|
|
**`rp_typecol` confirms it, and splits along a line predicted in advance.** Twelve kernels
|
|
(type x colour) instead of six, 4 seeds (0.8330, 0.8375, 0.8331, 0.8378):
|
|
|
|
```
|
|
arm prec@k pawn knight bishop rook queen king
|
|
rp 0.8161 0.7835 0.8481 0.7748 0.7837 0.7680 0.9227
|
|
rp_typecol 0.8353 0.8689 0.8580 0.7895 0.7615 0.7528 0.9127
|
|
delta +0.085 +0.010 +0.015 -0.022 -0.015 -0.010
|
|
shape 0.8305 0.8156 0.8624 0.8299 0.7679 0.7618 0.9134
|
|
```
|
|
|
|
The owner named the split before the run, from chess rather than from the data: colour and
|
|
starting square matter for the **pawn, bishop and knight**, and not for the **rook, queen and
|
|
king**. Giving each colour its own kernel gains on exactly the first three and **loses on
|
|
exactly the second three**. A capacity story predicts a uniform gain and is ruled out by the
|
|
sign flip.
|
|
|
|
The mechanism is a bias-variance trade made per piece type: splitting six kernels into twelve
|
|
halves the data behind each one. Where colour changes the law — a pawn's direction above all,
|
|
at +0.085 — that is worth paying. Where the law is colour-symmetric it is pure loss.
|
|
|
|
`rp_typecol` is the first arm to exceed the rule-knowing control **in aggregate** (0.8353
|
|
against 0.8305). Note that it does so by a different route than `rp`, which beat `shape` on
|
|
rook, queen and king while `rp_typecol` does not. Neither arm dominates; a kernel conditioned
|
|
on colour only for the pieces whose law depends on it is untested and is the obvious next
|
|
question.
|
|
|
|
## Limits
|
|
|
|
- One training pass, no schedule, no ordering. A graded curriculum (piece alone, then one
|
|
blocker, then a full board) has not been tried; the sampler is i.i.d.
|
|
- The model is still data-limited: 6k positions gave 0.41, 30k gave 0.61, 300k gives 0.82. It
|
|
had not plateaued at any budget measured.
|
|
- Legality of the *position* is not modelled: these are sampled placements, valid but not
|
|
reachable from the opening.
|
|
- Pins and check are excluded — the target is pseudo-legal. King safety is a global rule and a
|
|
separate question.
|
|
- `shape` is a control, not a ceiling: it scores 0.83 because it cannot see the board, and the
|
|
true ceiling is 1.0.
|
|
|
|
Reproduce with:
|
|
|
|
```bash
|
|
uv run --with chess python chess_rules.py --positions 300000 --seeds 0,1,2,3
|
|
uv run --with chess python chess_rules.py --positions 300000 --seeds 0,1,2,3 --arms rp_typecol
|
|
```
|