A strong UCI-compatible chess engine powered by a neural network trained solely on game results.
- Naive Bitboards
- Phased Move Generation
- Principal Variation Search
- Iterative Deepening
- Alpha-Beta Pruning
- Aspiration Windows
- Quiescence Search
- Static Exchange Evaluation (SEE)
- History Heuristic
- Killer Heuristic
- Counter Move Heuristic
- Follow-up Move Heuristic
- Late Move Reductions
- Null Move Pruning
- Zobrist Hashing
- Two-tier Transposition Table
- Partially Quantized Neural Network
- Configurable Architecture
- Training on Game Results Only
- SIMD Optimizations (SSE, AVX2)
Input Layer: 768 neurons (12 piece types × 64 squares)
↓
Hidden Layer: N neurons (configurable, e.g., 512)
↓
Output Layer: 3 neurons (Loss/Draw/Win probabilities)
The network uses dynamic quantization (int8) for the input-to-hidden layer weights to optimize inference performance.
The engine comes with three pre-trained models of different hidden layer sizes:
| Model | Hidden Layer Size | Model File | Weights File |
|---|---|---|---|
| 512 (default) | 512 | resources/models/512.pth |
resources/weights/512.weights |
| 256 | 256 | resources/models/256.pth |
resources/weights/256.weights |
| 1024 | 1024 | resources/models/1024.pth |
resources/weights/1024.weights |
Note: The 512 model is the default for release builds.
To use a different model, edit config/network.cfg and set the hidden_layer_size:
hidden_layer_size=<256/512/1024>Then rebuild the engine:
cargo build --releaseThe neural network is trained on chess game results using a multi-step pipeline that processes PGN data into training-ready format.
For details, reference to TrainingGuide.md.
The param_test utility tests engine parameters against EPD test suites.
cargo run --bin param_test [epd_file] [search_time_secs]The zobrist_key_gen utility generates optimal hash tables by testing multiple random seeds to minimize collisions.
cargo run --bin zobrist_key_gen [fen_file_path] [max_seeds_count]Pre-compiled binaries have been removed since 1.0 due to complexity in supporting multiple CPU features. Please compile directly from source code.
- Rust Nightly - This project requires Rust nightly for SIMD support. Install from rustup.rs
- Git - To clone the repository
- Python 3.10+ & PyTorch - Only needed for training new models
- jq - For parsing JSON metadata (required for build script)
Switch to Rust Nightly:
rustup install nightly
rustup default nightly
# Or override for just this project:
rustup override set nightly-
Clone the repository:
git clone https://github.com/your-repo/shallow-guess.git cd shallow-guess -
Verify model files:
- Trained models are in
resources/models/ - Exported weights are in
resources/weights/ - Configure model in
config/network.cfg
- Trained models are in
-
Build the engine:
export RUSTFLAGS="-C target-cpu=native" cargo build --release
-
Run the engine:
./target/release/shallow_guess
This engine includes SIMD optimizations for various CPU instruction sets. The build system automatically detects and uses the best available features based on your CPU.
| Feature | SIMD Types | SIMD Lane Width |
|---|---|---|
| AVX-512F | f32x16, i16x32 |
16 |
| AVX2/AVX | f32x8, i16x16 |
8 |
| SSE4.1/SSE2 | f32x4, i16x8 |
4 |
| Default | f32x4, i16x8 |
4 |
The target-cpu=native flag enables all available features for your CPU:
# Build with native CPU optimizations (recommended)
export RUSTFLAGS="-C target-cpu=native"
cargo build --releaseTo build for specific instruction sets, use:
# AVX-512F only
export RUSTFLAGS="-C target-feature=+avx512f"
cargo build --release
# AVX2 only
export RUSTFLAGS="-C target-feature=+avx2"
cargo build --release
# SSE4.1 only
export RUSTFLAGS="-C target-feature=+sse4.1"
cargo build --release
# Build for x86-64 baseline (SSE2)
export RUSTFLAGS="-C target-cpu=x86-64"
cargo build --releaseTo check which CPU features are available on your system:
# Linux
lscpu | grep "Flags"
# macOS
sysctl -n machdep.cpu.features
# Or check during build
cargo build --release 2>&1 | grep "target-feature"- x86_64: Full support for AVX-512F, AVX2/AVX, SSE4.1/SSE2
- aarch64: Support for ARM NEON (f32x4, i16x8)
- Other: Fallback to 4-lane SIMD
pgn-extract was used for extracting training positions from PGN files.
All training data for the latest release version was generated from historical 40/15 games downloaded from the CCRL website.
Training data for previous test versions was generated from TCEC tournament games.
Pseudo random number generator is a implementation of Chacha20 algorithm authored by Daniel J. Bernstein.