Skip to content
/ camel Public

Bitboard-based UCI-compatible chess/chess960 engine written from scratch in Rust.

License

Notifications You must be signed in to change notification settings

bdmendes/camel

Repository files navigation



Build Codecov Release

lichess-bullet lichess-blitz lichess-blitz

Overview

Camel is a chess and chess960 engine written from scratch in Rust. It aims to achieve a high level of play, while also being easy to understand and modify. It is primarily meant to be used within a GUI compatible with the UCI protocol, but may also be operated in a CLI.

Camel participates in various community chess engine competitions, such as the CCRL. It may also be seen playing on Lichess.

Compilation

Make sure you have an updated Rust environment on your machine. For best results, compile with LLVM optimizations enabled:

  $ cargo build --release

Testing

You can probe the integrity of the engine by running the test suite, which includes perft and other unit tests:

  $ cargo test

Upon development, to be able to claim a statistically significant improvement, it is recommended to set up a tournament against other version, using a utility such as fast-chess or cutechess-cli. For convenience, rely on the bundled script to automate the process using fast-chess:

  $ ./gauntlet.sh [BRANCH/TAG]

It is also possible and fun to deploy the engine to lichess, through the lichess-bot bridge. Please note, however, that the obtained Glicko rating is not directly comparable to FIDE's due to different player pools. With that in mind, you can simply use the bundled script to deploy the engine to lichess:

  $ ./deploy.sh

Usage

You can use a GUI such as Scid to be able to play against the engine or analyze a game. Alternatively, you can explore the engine through the interactive CLI, which builds on top of the UCI protocol, allowing you to visualize the board, make a move of your own, query legal moves and ask the engine to move.

  $ position fen r1q1k1r1/pp1np1b1/5npp/1Q1NN1p1/3P4/4B2P/PPP2PP1/4RRK1 w q - 3 16
  $ display
  ♜ - ♛ - ♚ - ♜ - 
  ♟ ♟ - ♞ ♟ - ♝ - 
  - - - - - ♞ ♟ ♟ 
  - ♕ - ♘ ♘ - ♟ - 
  - - - ♙ - - - - 
  - - - - ♗ - - ♙ 
  ♙ ♙ ♙ - - ♙ ♙ - 
  - - - - ♖ ♖ ♔ - 
  $ list
  e1e2 e1d1 e1c1 e1b1 e1a1 g1h1 g1h2 a2a3 a2a4 b2b3 b2b4 c2c3 c2c4 f2f3 f2f4 g2g3 g2g4 e3f4
  e3g5 e3d2 e3c1 h3h4 b5b6 b5b7 b5b4 b5b3 b5a5 b5c5 b5a6 b5c6 b5d7 b5a4 b5c4 b5d3 b5e2 d5c7
  d5e7 d5c3 d5b6 d5b4 d5f6 d5f4 e5d7 e5f7 e5d3 e5f3 e5c6 e5c4 e5g6 e5g4
  $ go depth 6
  info depth 1 score cp 324 time 4 nodes 598 nps 137134 pv e5g6
  info depth 2 score cp 324 time 13 nodes 598 nps 42912 pv e5g6 e7e6
  info depth 3 score cp 309 time 57 nodes 1715 nps 29579 pv e5g6 e7e6 g6e7
  info depth 4 score cp 309 time 226 nodes 4812 nps 21237 pv e5g6 e7e6 g6e7 a7a6
  info depth 5 score cp 307 time 1166 nodes 19830 nps 16992 pv e5g6 e7e6 g6e7 a7a6 b5d3
  info depth 6 score cp 312 time 3716 nodes 112194 nps 30189 pv e3g5 h6g5 e5d7 f6d7 d5e7 g7d4
  bestmove e3g5
  $ move e3g5
  $ display
  ♜ - ♛ - ♚ - ♜ - 
  ♟ ♟ - ♞ ♟ - ♝ - 
  - - - - - ♞ ♟ ♟ 
  - ♕ - ♘ ♘ - ♗ - 
  - - - ♙ - - - - 
  - - - - - - - ♙ 
  ♙ ♙ ♙ - - ♙ ♙ - 
  - - - - ♖ ♖ ♔ - 

Type help to see the available commands.

Design

Camel uses domain-specific techniques to achieve higher performance. The board is represented using bitboards and the move generation is aided by magics. The search is based on alpha-beta pruning, enhanced with a transposition table and extension and reduction schemas. Iterative deepening enables the time management framework.

Dive into the chess programming wiki to learn more about these techniques.

What can I do with it?

Camel is licensed under the GNU General Public License v3.0. You can use it for any purpose, including commercial use, provided you always include the license and the source code. Feel free to fork the repository and propose your changes.

Acknowledgments

  • Chess Programming Wiki: for the great explanations on the state of the art.
  • CCRL: for kindly including the engine in their competitions.
  • Lichess: for the friendly bot API.
  • Fast-Chess: for a lightweight, dependency-free way to set up engine matches.
  • @biromiro: for designing the cute camel logo.

Why Camel?

Camel likes to play active chess. It does grunt sometimes when it loses, though.