Skip to content

ptsouchlos/byte-knight

Repository files navigation

byte-knight

codecov

byte-knight is a UCI compliant chess engine written in Rust. It started as a port of the chess engine I submitted for Sebatian Lague's Chess Engine Challenge where it placed in the top 32 out of 600+ entries.

You can challenge byte-knight yourself on Lichess!

Overview

byte-knight is my first "real" Rust project. I'm a long time C++ developer and have been itching to learn Rust. I really enjoyed participating in the chess challenge a while back and thought that writing a new chess engine from scratch would be a good way to learn the language.

byte-knight is a command line chess engine and does not come with any sort of user interface. There are many chess GUIs out there that you can use like cutechess.

New features are tested on an OpenBench intance using SPRT testing.

Strength

Version CCRL 40/15 CCRL Blitz
3.0.0 2386 2311

Features

Board/Game Representation

  • Bitboard board representation
  • "Magic" bitboards or PEXT for sliding piece attacks
  • Zobrist hashing with board state history
  • Legal and pseudo-legal move generator with support for staged move generation

Search

Evaluation

  • Piece square tables with tapered evaluation using PeSTO values
  • Pawn structure (doubled, isolated and passed pawns)
  • Bishop pair bonus
  • King safety
  • Pawn storm and shield
  • Piece mobility
  • Rook open/semi-open files
  • Tempo bonus
  • Threat evaluation

Project includes a HCE tuner based on jw1912/hce-tuner and modified for use in byte-knight. HCE values have been trained on the lichess-big3-resolved dataset.

UCI

UCI is a standard protocol for chess engines. byte-knight implements the following commands:

  • uci
  • ucinewgame
  • isready
  • position <fen> moves <move list>
  • go
    • depth <depth>
    • nodes <nodes>
    • wtime <wtime> btime <btime> winc <winc> binc <binc>
  • stop
  • quit

Other Commands

To see all commands that byte-knight supports, type:

byte-knight help

To see all options for a given command, type byte-knight <cmd> --help.

  • bench - This runs a fixed depth search on a variety of positions. This is used by OpenBench for scaling based on engine performance.
  • perft - Run perft on a given FEN or EPD file for the given depth.
  • split-perft - Run split perft for a given FEN.

UCI Options

Name Value Range Default Description
Hash [1 - 1024] 16 Set the TT table size in MB
Threads [1] 1 How many threads to use in search

Build and Run

Clone the repo and run:

cargo -r run -p byte-knight

Development Dependencies

To run the full suite of supported tests, benchmarks and other development dependencies, you will need the following tools (in addition to Rust and Cargo):

  • just
  • Rust llvm-profdata component
    • Install with rustup component add llvm-tools-preview
  • grcov (Used to generate code coverage reports)
  • lcov (Required for genhtml to create HTML reports from lcov data)

License

The project is licensed under the GPL license. See LICENSE for more details.

Credits

Thanks/acknowledgement for those who have inspired and helped with this project:

  • Sebastian Lague for his chess YouTube vidoes and for hosting a fun coding challenge.
  • The Chess Programming Wiki for all the free information. Thank you to all the various authors.
  • Analog-Hors for some excellent write ups on chess, especially regarding magic numbers.
  • Many members of the Engine Programming discord for helping see how little I really know.
  • Danny Hammer for providing feedback, for helping me with troubleshooting my engine and for writing the chessie and uci-parser crates. Thanks for inspiring some of the techniques and methods used in byte-knight.
  • Marcel Vanthoor for his Rustic engine and associated book.
  • Everyone at pyrobench for donating CPU time as well as helping me when I get stuck.
  • Everyone at MattBench for donating CPU time as well as helping me when I get stuck.

Author


@ptsouchlos