User Interface

From Chessprogramming wiki
Jump to: navigation, search

Home * User Interface

User Interface of The Turk [1] [2] [3] [4] [5]

The User Interface is the space where Human-computer interaction takes place [6] . The user interface includes hardware (physical) and software (logical) components, and allow users to manipulate a system (Input), i.e. to enter moves inside a chess program, and the system to indicate the effects of the users' manipulation (Output), i.e. display moves and positions. Chess programs require support by the underlaying BIOS and operating system, accessible by embedded programming language features, or via an Application programming interface (API) of a standard or external library.


Dedicated chess computers have their own proprietary Input/output systems and programs, a robot, a mechanical intelligent agent, may interact like an human player, recognizing the moves either by incorporating a sensory board, or more sophisticated by computer vision [7] and real-time video image processing, and moving pieces with a mechatronical actuator and end effector.

The Game Loop

Early chess programs, running on mainframe computers, like The Bernstein Chess Program on an IBM 704, used a simple sequential control structure to play the whole game. As feedback for user interactions or indicating state transitions, for instance if the search finished with a move played on the internal board, ASCII diagrams and move lists were printed or displayed on a teleprinter, CRT (cathode ray tube) or any other Computer terminal, to prompt input which the user had to enter by a dedicated or standard teletype [8] keyboard. Initially, after start of the program, or during game play, while prompting a move, certain commands may be entered, either to switch modes, to set the game level, to start the game, to force or take-back a move, to switch sides, and whatever else. The usual syntax to input moves is to enter algebraic coordinates, that is file letter, rank number of origin and target square of a move to play, confirmed and sent to the program after entering carriage return.


The chess program and its user interface can be interpreted as a Model–view–controller (MVC), an architectural pattern that isolates business logic f.i. game administration, time management and searching a move inside a chess program from input and presentation. The game model represents the domain-specific data on which the application operates - Inside a chess program, the information about the initial position and the game record to reproduce the current positions, likely subject of search or pondering during game play. The model and controller implement a finite-state machine which controls the game, its states, state transitions and actions considering various modes. The view displays the game notation, a list of moves, and likely the board with the current position, suitable for interaction inside a user interface. The controller receives input from various sources and devices, such as keyboard, mouse, serial port and internet socket, and initiates a response by making calls on model objects.


see main article Command Line Interface.

Most current chess engines communicate via a sequential command-line interface, available in all common operating systems. Pondering and the need to enter moves and commands even if the program is "thinking", requires a more complicated control structure and an interruptible search routine. Often engines used coroutines to implement internal context switching between search and user interaction. Today, it is more common to rely on multithreading abilities of recent operating systems, and to use an explicit I/O-thread, while the search routine is regularly pondering whether it needs to be interrupted by pending input received by another thread, with the option to asynchronous stop the search.

Event driven GUIs

see main article Graphical User Interface.

With the advent of operating systems with graphical user interfaces, also encouraged by additional input devices such as a computer mouse for asynchronous user interaction, the embedding of a chess engine with a classical CLI inside the event-driven architecture of a graphical user interface became more difficult. Today, most programmers rely on an external event driven graphical user interface applications using standard streams or pipelines to communicate with the GUI via protocols such as the Chess Engine Communication Protocol and the Universal Chess Interface. The external GUI application constitutes the MVC view and controller, and more or less even parts of a (redundant) game model (or even multi-game model), to make the GUI aware of its own game states to even make decisions on behalf of the engine, such as move selection from opening books and endgame tablebases, draw claims and offers and to finally declare the game over. These game interacting features of the external GUI application in conjunction with certain protocols such as UCI by far exceeds what a pure chess user interface was initially designed for - controller and view only, enter legal moves and render the state of the game, which has become disputed issue in playing official tournament games.

UI Topics

See also


Forum Posts

External Links