# UCI The Universal Chess Interface, or UCI, is a specification for communication between chess engines[^1] and chess Graphical User Interfaces (GUIs)[^2]. In UCI, all communication is done via the standard input[^3] and standard output[^3] using a variety of [[Commands|text commands]]. ## Overview The overall flow of a session of chess using UCI is as follows: > [!info] > This example assumes a human user playing as white against an engine playing as black. If pitting two engines against one another, or an engine against itself, the sequence will look slightly different. Additionally, many UCI GUIs support local player vs player, in which case UCI itself never comes into play at all. We won't cover that case in this guide, since it doesn't technically have anything at all to do with UCI. 1. The user starts the GUI[^2] 2. The user selects a chess engine[^1] for the GUI to launch 3. The engine launches, **BUT DOES NOT DO ANYTHING YET** 4. The GUI sends the initial [[uci]] command to the engine, instructing the engine to use UCI mode 5. The engine identifies itself using the [[id]] command 6. The engine enumerates[^4] the options that can be configured for it using the [[option]] command 7. The engine indicates has finished sending [[option]] commands using the [[uciok]] command 8. If the user modifies any engine options, the GUI informs the engine using the [[setoption]] command 9. The GUI sends the [[isready]] command to ensure the engine has finished initialising 10. The engine responds with the [[readyok]] command as soon as it is ready to process more commands 11. When the game begins, the GUI sends the [[ucinewgame]] command 12. The GUI sends one or more [[position]] commands, setting up the initial board position. This is not necessarily the standard chess starting position 13. The user plays a move 14. The GUI sends one or more [[position]] commands to the engine to inform it about the current board state 15. The GUI sends the [[go]] command, prompting the engine to begin calculating 16. While calculating, the engine must use the [[UCI Docs/Commands/Engine/info|info]] command to provide the GUI with various statistics 17. When the engine has decided on a move, it sends the [[bestmove]] command 18. Steps 13-17 repeat until the game is concluded 19. Steps 11-18 repeat until the user either closes the GUI or selects a different engine [^1]: A chess engine is any computer program which plays chess. Typically, they use a machine-readable interface, so that they can be "plugged in" to a wide variety of interfaces, allowing great flexibility in terms of what opponents it can face. [Chess Programming Wiki](https://www.chessprogramming.org/Engines) [^2]: A [Graphical User Interface](https://www.chessprogramming.org/GUI) is a type of human-computer interface, which makes use of visual information on a computer display beyond what can be achieved solely with a sequential stream of text. [^3]: The [Standard Streams](https://en.wikipedia.org/wiki/Standard_streams) on modern operating systems are virtual devices that computer programs can interface with. The standard input and standard output on most modern operating systems consist of a stream of incoming or outgoing bytes (respectively), which are typically intended to be interpreted as text [^4]: The word "enumerate" has two subtly different common uses in software development. In this context, to enumerate a set of options simply means to systematically list all of the options in detail.