feat(official-bots): implement king-relative (HalfKP) encoding in NNUE (NCS-109) #82

Closed
Janis wants to merge 1 commits from feat/NCS-109-king-relative-encoding into main
Member

Replace absolute 768-feature encoding with dual-perspective king-relative
encoding (HalfKP style): each piece is encoded from both the white king's
and the black king's reference frame, yielding 98304 input features
(2 × 64 king-squares × 12 piece-types × 64 squares).

Key changes:

  • NNUE.scala: featureIdxWhite/featureIdxBlack replace featureIndex;
    pushAccumulator now accepts childBoard and recomputes on king moves
    (castle or normal king move) instead of using stale incremental state;
    non-king moves update both perspectives incrementally (~4 column ops).
  • EvaluationNNUE.scala: pass child.board to pushAccumulator.
  • python/src/train.py: fen_to_features produces 98304-dim HalfKP vector;
    NNUE model input size updated to INPUT_SIZE (98304); DEFAULT_HIDDEN_SIZES
    reduced to [512, 256, 128] appropriate for sparse high-dim input.
  • nnue_weights.nbai: replaced with placeholder 98304→16→8→1 model so
    tests compile and run; replace with a retrained model via Colab notebook.

Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com

Replace absolute 768-feature encoding with dual-perspective king-relative encoding (HalfKP style): each piece is encoded from both the white king's and the black king's reference frame, yielding 98304 input features (2 × 64 king-squares × 12 piece-types × 64 squares). Key changes: - NNUE.scala: featureIdxWhite/featureIdxBlack replace featureIndex; pushAccumulator now accepts childBoard and recomputes on king moves (castle or normal king move) instead of using stale incremental state; non-king moves update both perspectives incrementally (~4 column ops). - EvaluationNNUE.scala: pass child.board to pushAccumulator. - python/src/train.py: fen_to_features produces 98304-dim HalfKP vector; NNUE model input size updated to INPUT_SIZE (98304); DEFAULT_HIDDEN_SIZES reduced to [512, 256, 128] appropriate for sparse high-dim input. - nnue_weights.nbai: replaced with placeholder 98304→16→8→1 model so tests compile and run; replace with a retrained model via Colab notebook. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Janis added 1 commit 2026-06-24 19:33:31 +02:00
Replace absolute 768-feature encoding with dual-perspective king-relative
encoding (HalfKP style): each piece is encoded from both the white king's
and the black king's reference frame, yielding 98304 input features
(2 × 64 king-squares × 12 piece-types × 64 squares).

Key changes:
- NNUE.scala: featureIdxWhite/featureIdxBlack replace featureIndex;
  pushAccumulator now accepts childBoard and recomputes on king moves
  (castle or normal king move) instead of using stale incremental state;
  non-king moves update both perspectives incrementally (~4 column ops).
- EvaluationNNUE.scala: pass child.board to pushAccumulator.
- python/src/train.py: fen_to_features produces 98304-dim HalfKP vector;
  NNUE model input size updated to INPUT_SIZE (98304); DEFAULT_HIDDEN_SIZES
  reduced to [512, 256, 128] appropriate for sparse high-dim input.
- nnue_weights.nbai: replaced with placeholder 98304→16→8→1 model so
  tests compile and run; replace with a retrained model via Colab notebook.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Janis closed this pull request 2026-06-24 19:33:48 +02:00
Janis deleted branch feat/NCS-109-king-relative-encoding 2026-06-24 19:33:49 +02:00
Some checks are pending
Build & Test (NowChessSystems) TeamCity build finished

Pull request closed

Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: NowChess/NowChessSystems#82