/chai

UCI compatible chess engine playing at estimated ~2400 elo

Primary LanguageC++MIT LicenseMIT

chai - Chess Engine

UnitTest build

chai is a free UCI compatible chess engine playing at estimated ~2300 elo supporting state-of-the-art NNUE evaluation. In order to play or test this engine, a GUI like Arena, Lucas Chess or a command-line interface like c-chess-cli is recommended.

Installation

Prebuild Binaries

Latest prebuild binaries including different architectures and active NNUE are provided in releases. The engine speed between the architectures is avx2 > ssse3 > none. In case you do not know which architecture is supported on your CPU, you can either check with tools like HWINFO and CPUID or simply try to run the binaries (almost all somewhat modern CPUs support AVX2).

Building From Source in Linux

Building from source requires C++17 and Make. The target to build the engine is called release and has the following parameters:

  • comp Default is gcc. Set this to mingw to cross-compile and target windows binaries.
  • evalfile Here you can set the path with forward-slashes (!) to a NNUE file that should be included during compilation. Currently, no original NNUE files are offered. Instead, we refer to this repository where supported networks can be found. Note that nets can also be loaded via UCI protocol as explained in the UCI Options section.
  • avx2 Default is y. Set this to n if your CPU does not support AVX2.
  • ssse3 Default is y. Set this to n if your CPU does not support SSSE3.
$ git clone https://github.com/jakhac/chai
$ cd chai/src
$ make release [comp=compiler] [evalfile=path/to/evalfile.nnue] [avx2=y/n] [ssse3=y/n]

Testing, Strength, NNUE

NNUE

When starting to completely refactor the evaluation of this engine, NNUEs were already state-of-the-art and used by most top engines. Instead of tweaking parameters of an handcrafted evaluation and spending numerous resources to incrementally measure and verify small strength improvements (based on outdated heuristics), a support for NNUE files is implemented in the latest release. However, as own networks are not offered yet, we refer to networks trained by RubiChess which are supported by chai. In fact, the NNUE engines listed in the table below utilize these nets.

Elo

The engines are mainly tested by self-play and occasionally checked against additional engines provided by CCRL for better reference. The time controls are mostly 20/0.3 and 40/0.4. Engine testing differs on various machines and therefore, the following data is only an estimation derived from an Intel i5-6500 setup.

Engine Elo
chai_v3.4.0_1CPU 2313
chai_v3.4.0_4CPU 2438
chai_v3.4.0_1CPU_nnue 3109
chai_v3.4.0_4CPU_nnue 3221

Features

UCI Options

The engine implements the UCI protocol and contains the following options:

  • Adjust the size of the hashtable in Mb
setoption name Hash value <value>
  • Set number of threads
setoption name Threads value <value>
  • Load a NNUE file
setoption name EvalFile value <path/to/nnue.bin>
  • Enable EGTB by providing path to Syzygy EG-Files:
setoption name SyzygyPath value <path/to/egtb_files>

Engine Features

An excerpt of applied techniques and heuristics is listed in the following:

  • Search
    • Multi-threaded iterative deepening framework based on Lazy SMP
    • Principal variation search
    • Late move Reductions
    • Transposition Table (4 buckets: replace entry with lowest depth)
  • Evaluation
    • NNUE evaluation as outlined by Gary Linscott in nnue-pytorch. The implementation follows the classical HalfKP Feature-Set that was implemented in Stockfish 13.1.
  • Perft
    • Use perft option to debug your move generator. Each run contains statistics about captures, checks, mates (..)
    • Optimized perft option using all available cores for deep perfting results
  • Move Generation
    • Bitboard based move generation with Magic-Bitboards
    • Special generators for quiescence and check evasions
    • Checker generator (generates all checking moves for first ply of quiescence)
  • Endgame Tablebase Probing (Fathom probing tool)
  • Test-Suite based on GoogleTest-Framework (for usage see here)

Acknowledgement

Following sources supported and influenced development: