Files
chess-engine/python
KeshavAnandCode 0d2843d2d4 feat: implement EXACT Stockfish NNUE feature encoding
- FullThreats formula: from_piece_idx * 157 + to_piece_idx
- 24 HalfKAv2_hm + 79 FullThreats = 103 features
- Max index: 60,514 (within 60,720 Stockfish limit)
- Matches Stockfish's exact encoding structure
- All tests passing (11/11)
2026-04-14 18:57:17 -05:00
..

Chess NNUE Distillation

Train a single linear layer on Stockfish's NNUE features.

Quick Start

cd python
source .venv/bin/activate
pip install torch --index-url https://download.pytorch.org/whl/cu121
pip install numpy python-chess tqdm matplotlib h5py joblib pytest
python train_full.py

Architecture

  • Input: 61,072 features (352 HalfKAv2_hm + 60,720 FullThreats)
  • Output: 1 scalar (centipawns)
  • Optimizer: Adam (lr=1e-3, wd=1e-4)