The Universal Chess Interface (UCI) is an open communication protocol that enables chess engines to communicate with user interfaces. [1] [2]
In November 2000, the UCI protocol was released. Designed by Rudolf Huber and Stefan Meyer-Kahlen, the author of Shredder, UCI rivals the older "Chess Engine Communication Protocol" introduced with XBoard/WinBoard.
In 2002, Chessbase, the chess software company which markets Fritz, began to support UCI, which had previously been supported by only a few interfaces and engines.
As of 2021 [update] , well over 300 engines are known to directly support UCI.
By design, UCI assigns some tasks to the user interface (i.e., presentation layer) which have traditionally been handled by the engine (at the business layer) itself.[ citation needed ]
Most notably, the opening book is usually expected to be handled by the UI, by simply selecting moves to play until it is out of book, and only then starting up the engine for calculation in the resulting position. UCI does not specify any on-disk format for the opening book. Different UIs usually have their own proprietary formats.[ citation needed ]
While the UI can also take responsibility for handling endgame tablebases, this is arguably better handled in the engine itself, as having tablebase information can be useful for considering possible future positions. [3]
Stefan-Meyer Kahlen's UCI protocol in Shredder uses a variation of long algebraic notation for moves. A "nullmove" from an engine to a GUI should be sent as 0000. [4]
There are many commands used to communicate with an engine. [5]
| Command | Usage | Description | Response |
|---|---|---|---|
| quit | quit | Closes the chess engine | N/a |
| uci | uci | Tells the engine to switch to UCI mode | uciok |
| ucinewgame | ucinewgame | Used to let the engine know that the next position it receives will be from a different game. | N/a |
| isready | isready | Used to synchronize the engine. Use after sending a command that might take some time. | readyok |
| setoption | setoption name <id> [value <x>] | Used to change the internal parameters of a chess engine. | N/a |
| position | position [fen <fenstring> | startpos ] moves <move1> .... <movei> | Used to tell the engine to setup the provided position. | N/a |
| go | go [infinite | depth <depth> | nodes | mate] searchmoves <move1> .... <movei> ponder wtime <x> btime <x> winc <x> binc <x> movestogo <x> nodes <x> movetime <x> perft <x> | Tells the engine to start calculation. | bestmove <move> ponder <expected> |
| stop | stop | Tells the engine to halt calculation as soon as possible. | N/a |
| ponderhit | ponderhit | Tells the engine that the player has played the expected move. | N/a |
There are also some optional commands implemented in engines like Stockfish. [5]
| Command | Usage | Description | Response |
|---|---|---|---|
| bench | bench [ttSize] [threads] [limit] [fenFile] [limitType] | Runs a benchmark test on the engine. | Test data |
| speedtest | speedtest [threads] [hash (MiB)] [runtime (s)] | Measures the speed of the computer running the engine. | Test data |
| d | d | Prints an ASCII representation of the board in the current state. | ASCII Board |
| eval | eval | Displays the static evaluation of the board. | Scaled Evaluation |
| compiler | compiler | Prints information about the engine's compiler. | Compiler info |
| export_net | export_net [filenameBigNet] [filenameSmallNet] | Exports the currently loaded network into a file. | N/a |
| flip | flip | Flips the side to move. | N/a |
| help | help | In Stockfish, this command prints information about the chess engine and links to the Github. | Help text. |
| license | license | Same as help command. | Help text. |
The uci_limitstrength parameter tells engines with this feature to play at a lower level. The uci_elo parameter specifies the Elo rating at which the engine will aim to play. Engines that have implemented uci_elo include Delfi, Fritz, Hiarcs, Houdini, Junior, Rybka, Shredder, Sjeng and Stockfish.
The UCI has been modified to play some other games, and chess variants. Some of these are: [6]
Each of these protocols may also define variants of Portable Game Notation (PGN) and Forsyth–Edwards Notation (FEN). The XBoard CECP is said to require far fewer changes to support variants. [6]