Chess Game

From Chessprogramming wiki
Jump to: navigation, search

Home * Chess * Game

A Game of Chess [1]

The Game of Chess which is actually played (or analyzed) by a chess program via its user interface requires a game record, or game history, which is a list or array of moves or a tree of alternative move variants even containing comments. While the game record is necessary to take back moves f.i. after operator errors, the game history needs to be considered if it is about to claim or accepts draws by three fold repetitions, and might therefor be referred by the search algorithm as well.

Start of the Game

The game of chess starts with the initial position, white to move. Both sides alternately move their pieces until the game is finished.

End of the Game

There are three possible outcomes of the game, white wins (1-0), black wins (0-1) or draw (1/2-1/2). Unfinished games may be adjudicated, which was common until the 80s in computer chess tournaments, for instance the adjudicated win of Cray Blitz against Schach 2.7 during WCCC 1986 [2] . Checkmate and stalemate finish the game immediately. Other occurrences usually require communication with the opponent and admission or adjudication of an arbiter instance (i.e. Tournament director), which in computer chess requires a protocol and/or interaction, like claiming a threefold repetition draw in over the board computer chess.

see main article Rules of Chess

Win/Loss

Since chess is a Zero-sum game, the win of one player is the loss of the other player.

Draw

The game of chess ends and is draw after either

Game Record

Chess programs (not necessarily the pure (search) engine) keep track of all moves played in the game from the initial starting position stored inside a move list, often in conjunction with a list of Zobrist or BCH signatures of the up to 100 last reversible moves for the purpose to detect twofold or threefold repetitions.

Game Header

The game header keeps metadata of a game, such as player names, date of the game and site of the event and result. For instance, the PGN game header consists of a set of attribute value pairs. The so called Seven Tag Roster (STR) is mandatory [3]:

  1. Event (the name of the tournament or match event)
  2. Site (the location of the event)
  3. Date (the starting date of the game)
  4. Round (the playing round ordinal of the game)
  5. White (the player of the white pieces)
  6. Black (the player of the black pieces)
  7. Result (the result of the game)

Longest Game

In 1966, Eero Bonsdorff, Karl Fabel, and Olvai Riihimaa gave 5899 as the maximum number of moves in a chess game, considering the Fifty-move Rule [4] [5] [6].

MVC

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.

The Game Loop

Early chess programs without Pondering used a simple sequential control structure to play the whole game for instance via a teleprinter or any Computer terminals in a sequential manner.

state := playGame;
initialize position
print board
while (state != gameover)
   wait for input of a move by the user
   make move (if legal)
   if (mate or stalemate) {
      state := gameOver;
      break;
   }
   search move with allocated time
   make move
   print move and update board
   if (mate or stalemate)
      state := gameOver;
}
print "thank you for playing the game";

CLI

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

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 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.

See also

Publications

Forum Posts

2010 ...

2020 ...

External Links

References

  1. A Game of Chess in the Middle Ages, Image photographed from an explanation table labeled "Die Essener Isenburg" at the Isenburg Castle in Essen, Germany, by Gerd Isenberg, September 28, 2015
  2. Helmut Horacek, (1986) The Fifth World Computer Chess Championship Cologne, 1986, Research Unit for Information Science and Artificial Intelligence, University of Hamburg, from Kings move Welcome to the 1989 AGT World Computer Chess Championship. pg 21, pdf from The Computer History Museum
  3. Standard: Portable Game Notation Specification and Implementation Guide by Steven Edwards, 8.1.1: Seven Tag Roster
  4. Eero Bonsdorff, Karl Fabel, Olvai Riihimaa (1966) Schach und Zahl - Unterhaltsame Schachmathematik. Seite 11-13, Walter Rau Verlag, Düsseldorf (German)
  5. 50-Züge-Regel - Schachmathematik from Wikipedia.de (German)
  6. Defending Humanity's Honor by Tim Krabbé, see game NewRival - Faile with 493 moves, and playing 402 moves with bare kings!
  7. Claude Shannon, Shannon number, Godfrey Harold Hardy, A googolplex of Go games

Up one Level