io-chess
UCI chess engine
Loading...
Searching...
No Matches
Feature Extraction

Feature extraction is the most computationally intensive part of the preprocessing pipeline. Each chess position is encoded into a set of spatial feature planes (8×8 grids) and scalar features that together capture the essential information about the position.

Factorized Features (v2)

The FactorizedFeatureExtractor computes the current feature set used by the Factorized MoE network. Features are grouped into categories:

Piece Placement Planes

Twelve binary 8×8 planes (one per piece type and colour) encoding the presence of each piece on each square. These are the most basic input features and provide the foundation for all other computations.

Chebyshev Distance Maps

Distance metrics between key squares, computed using Chebyshev distance (the number of king moves required to travel between two squares):

  • King-to-piece distances: For each piece, the Chebyshev distance to both the friendly and enemy king. These capture king safety (is a piece near the opponent's king?) and endgame dynamics (is the king near a passed pawn?).
  • King-to-king distance: The distance between the two kings, which is a strong signal for endgame evaluation (opposition, king activity).

Pawn Structure Encodings

Pawn-specific structural features computed from the pawn bitboards:

Feature Description
Passed pawns Pawns with no opposing pawns ahead on the same or adjacent files
Backward pawns Pawns that cannot advance without being captured and have no friendly pawn support
Isolated pawns Pawns with no friendly pawns on adjacent files
Doubled pawns Multiple pawns of the same colour on the same file
Front-span maps The set of squares ahead of each pawn, encoding pawn chains and pawn breaks

Slider Ray Alignments

Attack and pin ray maps for sliding pieces (bishops, rooks, queens) relative to the kings:

  • Pin ray maps: Squares on a ray between a slider and the enemy king that contain a single intervening piece (a potential pin target).
  • X-ray maps: Rays that pass through a piece to attack a square behind it.

Scalar Features

  • Castling rights (4 bits: white/black kingside/queenside).
  • En-passant target square.
  • Side to move.

Expert Routing Labels

The ExpertRouter classifies each position into one of four categories that correspond to the MoE experts. These labels are used during Phase 2 (Router Warm-Up) and Phase 3 (Expert Specialisation) of training:

Category Heuristic
Tactical High capture/check potential, queen present, threats
Strategical Middlegame with stable pawn structure, no immediate tactics
Major endgame ≤ 1 minor piece per side, rook or queen present
Minor endgame Only minor pieces and pawns remain
See also
FactorizedFeatureExtractor, ExpertRouter

Legacy Features (v1)

The older FeatureExtractor uses a simpler set of input features (piece-only planes without distance maps or pawn structure) and produces a different binary layout. It is retained for backward compatibility with v1 model weights and is not used by the current training pipeline.

See also
FeatureExtractor