How harborg1/chesscnn works
This project recognizes a chessboard image as a position, converts its square-wise CNN predictions into FEN, then asks the bundled Stockfish engine for a best move. The Python source excerpt shows image preprocessing, dataset construction, training, and model-weight saving; the README documents the image-to-FEN-to-engine workflow. Stockfish’s UCI entry and engine search are represented using the available source and file tree. The runner’s implementation was not sampled, so its exact process and data-transfer details are uncertain.
Main entry points: search.cpp Move search · app.py Chess CNN · uci.cpp UCI interface · engine.cpp Engine orchestration
Components 16
Position recognition
- Image preprocessing
app.py - Training dataset
app.py - Chess CNN
app.py - Model weights
app.py - FEN conversion
app.py
Engine integration
- Position runner
run_stockfish.py
Stockfish engine
- Stockfish process
stockfish-windows-x86-64-avx2/stockfish/src/main.cpp - UCI interface
stockfish-windows-x86-64-avx2/stockfish/src/uci.cpp - Engine orchestration
stockfish-windows-x86-64-avx2/stockfish/src/engine.cpp
Search and evaluation
- Board position
stockfish-windows-x86-64-avx2/stockfish/src/position.cpp - Move search
stockfish-windows-x86-64-avx2/stockfish/src/search.cpp - Move generation
stockfish-windows-x86-64-avx2/stockfish/src/movegen.cpp - NNUE evaluation
stockfish-windows-x86-64-avx2/stockfish/src/nnue/network.cpp - Syzygy tables
stockfish-windows-x86-64-avx2/stockfish/src/syzygy/tbprobe.cpp
Other components
- Chess position image
- Suggested move
Connections 17
- Chess position image → Image preprocessing: provides image
- Image preprocessing → Chess CNN: prepares squares
- Training dataset → Image preprocessing: loads images
- Training dataset → Chess CNN: trains model
- Chess CNN → Model weights: saves weights
- Chess CNN → FEN conversion: predicts squares
- FEN conversion → Position runner: supplies FEN
- Model weights → Position runner: loads model
- Position runner → Stockfish process: starts engine
- Stockfish process → UCI interface: enters UCI loop
- UCI interface → Engine orchestration: dispatches commands
- Engine orchestration → Board position: sets position
- Engine orchestration → Move search: starts search
- Move search → Move generation: generates moves
- Move search → NNUE evaluation: evaluates positions
- Move search → Syzygy tables: probes endings
- UCI interface → Suggested move: reports best move