dannyhammer / toad

A UCI compatible chess engine
Mozilla Public License 2.0
4 stars 0 forks source link

Toad - A UCI-compatible toy chess engine

Toad is a work-in-progress chess engine, and serves as my personal excuse to write fun code in Rust. It was originally built upon my chessie crate, which is a chess library that handles board representation, move generation and all other rules of chess.

Up for a game? Play against Toad on Lichess!

Overview

By default, running Toad will cause it to print its version and authors and await input via stdin. For convenience, you can run any of Toad's commands on startup and Toad will exit immediately after that command's execution. To run multiple commands on startup, pass them in with the -c "<command>" flag. You can pass in the --no-exit flag to continue execution after the command(s) have finished executing. Run the engine and execute the help command to see a list of available commands, and --help to view all CLI flags and arguments.

UCI

Toad abides (mostly) by the Universal Chess Interface protocol, and communicates through stdin and stdout. The parsing of UCI commands and responses is handled by my uci-parser crate.

The following UCI commands (and arguments) are supported:

Custom Commands

In addition to the above UCI commands, Toad also supports the following custom commands:

Commands:
  await       Await the current search, blocking until it completes
  bench       Run a benchmark with the provided parameters
  display     Print a visual representation of the current board state
  eval        Print an evaluation of the current position
  exit        Quit the engine
  fen         Generate and print a FEN string for the current position
  flip        Flips the side-to-move. Equivalent to playing a nullmove
  hashinfo    Display information about the current hash table(s) in the engine
  makemove    Apply the provided move to the game, if possible
  moves       Shows all legal moves in the current position, or for a specific piece
  option      Display the current value of the specified option
  perft       Performs a perft on the current position at the supplied depth, printing total node count
  psqt        Outputs the Piece-Square table value for the provided piece at the provided square, scaled with the endgame weight
  splitperft  Performs a split perft on the current position at the supplied depth
  help        Print this message or the help of the given subcommand(s)

For specifics on how a command works, run toad <COMMAND> --help

UCI Options

Name Values Default Description
Clear Hash Clear the hash table(s)
Hash 1..=1024 16 Set the size (in MB) of the hash table(s)
Threads 1..=1 1 Only implemented for use with OpenBench
UCI_Chess960 true, false false Enable support for Chess960

Running

To run Toad, head over to the releases page to grab the latest pre-compiled release for your platform. Alternatively, you can build from source:

  1. Ensure you have Rust and Cargo installed.
  2. Clone this repository:
    git clone git@github.com:dannyhammer/toad.git
  3. Build and run!
    cargo run --release

    or run make to generate an executable named toad-<version>.

    make
    ./toad-<version>

Note: Development has primarily been done on Linux (Ubuntu 22.04), with minimal testing on Windows 10 and no testing on MacOS. If you are willing to test the installation and execution of Toad on other operating systems, please provide feedback!

Features

More features will be added as development continues! You can see most of my future plans in the backlog.

Acknowledgements

More people have helped me on this journey than I can track, but I'll name a few notable resources/people here: