Skip to content

About

A UCI chess engine written in Rust.

Resources

Stars

6 stars

Watchers

1 watching

Forks

Repository files navigation

Rusty Rival

A UCI chess engine written in Rust. Please take a look at the UCI Documentation for usage instructions.

Binaries for Windows, Mac OS and Linux are available on the releases page.

Play Online

Rusty Rival plays on Lichess as RustyRival.

Lichess hardware & configuration:

  • Apple M1 Max (10 cores: 8 performance + 2 efficiency), 64 GB RAM
  • Threads: 8
  • Hash: 512 MB
  • Ponder: enabled
  • Move Overhead: 0 (handled by lichess-bot at 500ms)

Watch

Rival Chess has a YouTube channel and a set of chess lessons at rivalchess.com/learn.

The video How Do Chess Engines Actually Work? explains engine internals using Rival, including its magic bitboards and a real castling bug found with perft.

Features

  • NNUE evaluation with embedded network (can fall back to handcrafted evaluation)
  • Alpha-beta search with iterative deepening and aspiration windows
  • Lazy SMP multi-threaded search (configurable via UCI Threads option)
  • Ponder support
  • Transposition table, killer moves, history heuristic, countermove heuristic
  • Null move pruning, late move reductions, late move pruning, reverse futility pruning
  • Singular extensions, probcut, multi-cut, SEE pruning
  • Quiescence search with static exchange evaluation
  • Syzygy endgame tablebase support
  • SPSA-tuned evaluation and search parameters
  • Chess960 (Fischer Random): castling from any start position, Shredder-FEN and X-FEN castling fields, UCI_Chess960 move notation

Building

  1. Build the engine:

The engine can be about 50% faster if compiled on the machine on which it will be run in order to take advantage of cpu-specific instructions. To compile locally, it requires that Rust be installed.

Linux/macOS:

RUSTFLAGS="-C target-cpu=native" RUST_MIN_STACK=4097152 cargo build --release

Windows (PowerShell):

$env:RUSTFLAGS="-C target-cpu=native"; $env:RUST_MIN_STACK=4097152; cargo build --release

Windows (cmd.exe):

set RUSTFLAGS=-C target-cpu=native
set RUST_MIN_STACK=4097152
cargo build --release

Note: .cargo/config.toml sets -C target-cpu=native for local builds by default to maximize performance. This makes the binaries non-portable across different CPUs. The release workflow overrides this to keep published binaries portable. 2. Store the executable in engines directory:

mkdir -p engines/v020-my-feature
cp target/release/rusty-rival engines/v020-my-feature/
git tag v020-my-feature

UCI Options

Option Type Default Range Description
Hash spin 256 1–16384 Transposition table size in MB.
Clear Hash button — — Clears the transposition table.
Threads spin 1 1–256 Number of search threads (Lazy SMP).
UseNNUE check true — Use the NNUE neural network evaluation. When disabled, falls back to handcrafted evaluation.
MultiPV spin 1 1–20 Number of lines to report. Line 1 is the searched principal variation. Lines 2 and up are the root loop's null-window results for the runners-up, reported as upperbound scores with their refutation lines; they are not fully searched variations.
SyzygyPath string <empty> — Path to Syzygy endgame tablebase files.
Contempt spin 0 -1000–1000 Contempt factor for draw avoidance. Positive values make the engine avoid draws.
EvalNoise spin 0 0–100 Adds random noise to the evaluation for varied play.
Ponder check false — Enable pondering (thinking on the opponent's time).
Move Overhead spin 10 0–5000 Time in ms reserved per move for communication overhead.
UCI_ShowWDL check false — Show win/draw/loss probabilities in search output.
UCI_Chess960 check false — Write castling as the king taking its own rook (e1h1), as the Chess960 UCI convention requires. Input always accepts king-takes-rook, and accepts the standard spelling (the king's own move to the g or c file, such as e1g1) when the king moves at least two squares; a castle in which the king moves one square or none must be sent as king-takes-rook, and the engine writes such castles that way in both modes. Castling legality does not depend on the option: a Chess960 FEN (HAha or KQkq castling field) castles correctly either way.

License

Copyright (C) 2021-2026 Chris Moreton.

Rusty Rival is free software, released under the GNU General Public License, version 3 or (at your option) any later version. See LICENSE for the full text.

The engine links the GPL-3.0-or-later crates shakmaty and shakmaty-syzygy for Syzygy tablebase probing, so binaries built from this repository must be distributed under the same terms. The LICENSE file is attached to every GitHub release alongside the binaries.

About

A UCI chess engine written in Rust.

Resources

Stars

6 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages