Update
This commit is contained in:
parent
ae83a3d0c0
commit
1ab3672b68
7 changed files with 179 additions and 69 deletions
137
chess.md
137
chess.md
|
@ -23,6 +23,13 @@ Chess as a game is not and cannot be [copyrighted](copyright.md), but **can ches
|
|||
|
||||
Chess evolved from ancient board games in India in about 6th century. Nowadays the game is internationally governed by **FIDE** which has taken the on role of an authority that defines the official rules: FIDE rules are considered to be the standard chess rules. FIDE also organizes tournaments, promotes the game and keeps a list of registered players whose performance it rates with so called Elo system – based on the performance it also grants titles such as **Grandmaster** (GM, strongest), **Internation Master** (IM, second strongest) or **Candidate Master** (CM). A game of chess is so interesting in itself that chess is usually not played for money like many other games ([poker](poker.md), [backgammon](backgammon.md), ...).
|
||||
|
||||
The mastery of chess is often divided into two main areas (it is also common to divide strong players into these two categories depending on where their main strength lies):
|
||||
|
||||
- **positional play**: Long term, big picture patterns that offer many advantages and opportunities for playing good moves, trying to get a "good position" with men on strong squares, controlling key parts of the board, putting pressure on enemy, ensuring safety of own king etc.
|
||||
- **tactical play**: Short term, quick action, tricks and calculation skills that win advantages, often material, with tools like forks, pins, discovery checks, sacrifices etc.
|
||||
|
||||
Of course this is not the only possible division, another one may be for example offensive vs defensive play etc., but generally chess revolves around position and tactics.
|
||||
|
||||
A single game of chess is seen as consisting of three stages: **opening** (starting, theoretical "book" moves, developing men), **middlegame** (seen as the pure core of the game) and **endgame** (ending in which only relatively few men remain on the board). There is no clear border between these stages and they are sometimes defined differently, however each stage plays a bit differently and may require different skills and strategies; for example in the endgame king becomes an active man while in the opening and middlegame he tries to stay hidden and safe.
|
||||
|
||||
The study of chess openings is called **opening theory** or just *theory*. Playing the opening stage is special by being based on memorization of this theory, i.e. hundreds or even thousands of existing opening lines that have been studied and analyzed by computers, rather than by performing mental calculation (logical "thinking ahead" present in middlegame and endgame). Some see this as weakness of chess that makes players spend extreme energy on pure memorization. One of the best and most famous players, Bobby Fischer, was of this opinion and has created a chess variant with randomized starting position that prevents such memorization, so called *chess 960*.
|
||||
|
@ -47,78 +54,19 @@ On **perfect play**: as stated, chess is unlikely to be ever solved so it is unk
|
|||
|
||||
Chess is a big topic in computer science and programming, computers not only help people play chess, train their skills, analyze positions and perform research of games, but they also allow mathematical analysis of chess and provide a platform for things such as [artificial intelligence](ai.md).
|
||||
|
||||
Chess software is usually separated to **libraries**, **chess engines** and **frontends** (or boards). Chess engine is typically a [CLI](cli.md) program capable of playing chess but also doing other things such as evaluating arbitrary position, hinting best moves, saving and loading games etc. Frontends on the other hand are [GUI](gui.md) programs that help people interact with the underlying engine.
|
||||
Chess software is usually separated to **[libraries](library.md)**, **chess engines** and **[frontends](frontend.md)**. Chess engine is typically a [CLI](cli.md) program capable of playing chess but also doing other things such as evaluating arbitrary position, hinting best moves, saving and loading games etc. -- commonly the engine has some kind of custom CLI interface (flags, interactive commands it understands, ...) plus a support of some standardized text communication protocol, most notably XBoard (older one, more [KISS](kiss.md)) and UCI (newer, more [bloated](bloat.md)). There is also typically support for standardized formats such as FEN (way of encoding a chess position as a text string), PGN (way of encoding games as text strings) etc. Frontends on the other hand are usually [GUI](gui.md) programs (in this case also called *boards*) that help people interact with the underlying engine, however there may also be similar non-GUI programs of this type, e.g. those that automatically run tournaments of multiple engines.
|
||||
|
||||
For communication between different engines and frontends there exist standards such as XBoard (engine [protocol](protocol.md)), UCI (another engine protocol), FEN (way of encoding a position as a string), PGN (way of encoding games as strings) etc.
|
||||
|
||||
Computers have already surpassed the best humans in their playing strength (we can't exactly compute an engine's Elo as it depends on hardware used, but generally the strongest would rate high above 3000 FIDE). As of 2021 the strongest chess engine is considered to be the [FOSS](foss.md) engine [Stockfish](stockfish.md), with other strong engines being e.g. Leela Chess Zero (also FOSS) or AlphaZero ([proprietary](proprietary.md), by [Google](google.md)). [GNU Chess](gnu_chess.md) is a pretty strong [free software](free_software.md) engine by [GNU](gnu.md). There are world championships for chess engines such as the *Top Chess Engine Championship* or *World Computer Chess Championship*. [CCRL](https://ccrl.chessdom.com/ccrl/4040/) is a list of chess engines along with their Elo ratings. Despite the immense strength of modern engines, there are still very specific situation in which humans beat the computer (shown e.g. in [this](https://www.youtube.com/watch?v=R9IZWgArWUE) video).
|
||||
Computers have already surpassed the best humans in their playing strength (we can't exactly compute an engine's [Elo](elo.md) as it depends on hardware used, but generally the strongest would rate high above 3000 FIDE). As of 2023 the strongest chess engine is widely agreed to be the [FOSS](foss.md) engine [Stockfish](stockfish.md), with other strong engines being e.g. Leela Chess Zero (also FOSS), AlphaZero ([proprietary](proprietary.md) by [Google](google.md)) or Komodo Dragon (proprietary). [GNU Chess](gnu_chess.md) is a pretty strong [free software](free_software.md) engine by [GNU](gnu.md). There are world championships for chess engines such as the *Top Chess Engine Championship* or *World Computer Chess Championship*. [CCRL](https://ccrl.chessdom.com/ccrl/4040/) is a list of chess engines along with their Elo ratings deduced from tournaments they run. Despite the immense strength of modern engines, there are still some specific artificial situations in which a human beats the computer (shown e.g. in [this](https://www.youtube.com/watch?v=R9IZWgArWUE) video); this probably won't last long though.
|
||||
|
||||
The first chess computer that beat the world champion (at the time Gary Kasparov) was famously [Deep Blue](deep_blue.md) in 1997. [Alan Turing](turing.md) himself has written a chess playing algorithm but at his time there were no computers to run it, so he executed it by hand -- nowadays the algorithm has been implemented on computers (there are bots playing this algorithm e.g. on lichess).
|
||||
|
||||
For online chess there exist many servers such as https://chess.com or https://chess24.com, but for us the most important is https://lichess.org which is gratis and uses [FOSS](foss.md) (it also allows users to run bots under special accounts which is an amazing way of testing engines against people and other engines). These servers rate players with Elo/Glicko, allow them to play with each other or against computer, solve puzzles, analyze games, play chess variants, explore opening databases etc.
|
||||
|
||||
Playing strength is not the only possible measure of chess engine quality, of course -- for example there are people who try to make the **smallest chess programs** (see [countercomplex](countercomplex.md) and [golfing](golf.md)). As of 2022 the leading programmer of smallest chess programs seems to be Óscar Toledo G. (https://nanochess.org/chess.html). Unfortunately his programs are [proprietary](proprietary.md), even though their source code is public. The programs include Toledo Atomchess (392 [x86](x86.md) instructions), Toledo Nanochess (world's smallest [C](c.md) chess program, 1257 non-blank C characters) and Toledo Javascript chess (world's smallest [Javascript](javascript.md) chess program). He won the [IOCCC](ioccc.md). Another small chess program is micro-Max by H. G. Muller (https://home.hccnet.nl/h.g.muller/max-src2.html, 1433 C characters, Toledo claims it is weaker than his program).
|
||||
Playing strength is not the only possible measure of chess engine quality, of course -- for example there are people who try to make the **smallest chess programs** (see [countercomplex](countercomplex.md) and [golfing](golf.md)). As of 2022 the leading programmer of smallest chess programs seems to be Óscar Toledo G. (https://nanochess.org/chess.html). Unfortunately his programs are [proprietary](proprietary.md), even though their source code is public. The programs include Toledo Atomchess (392 [x86](x86.md) instructions), Toledo Nanochess (world's smallest [C](c.md) chess program, 1257 non-blank C characters) and Toledo Javascript chess (world's smallest [Javascript](javascript.md) chess program). He won the [IOCCC](ioccc.md). Another small chess program is micro-Max by H. G. Muller (https://home.hccnet.nl/h.g.muller/max-src2.html, 1433 C characters, Toledo claims it is weaker than his program). Other engines try to be strong while imitating human play (making human moves, even mistakes), most notably Maia which trains several neural networks that play like different rated human players.
|
||||
|
||||
{ Nanochess is actually pretty strong, in my testing it easily beat [smallchesslib](smallchesslib.md) Q_Q ~drummyfish }
|
||||
|
||||
## Stats And Records
|
||||
|
||||
Chess stats are pretty [interesting](interesting.md).
|
||||
|
||||
{ Some chess world records are here: https://timkr.home.xs4all.nl/records/records.htm. ~drummyfish }
|
||||
|
||||
**Number of possible games** is not known exactly, Shannon estimated it at 10^120 (lower bound, known as *Shannon number*). Number of possible games by plies played is 20 after 1, 400 after 2, 8902 after 3, 197281 after 4, 4865609 after 5, and 2015099950053364471960 after 15.
|
||||
|
||||
Similarly the **number of possibly reachable positions** (position for which so called *proof game* exists) is not known exactly, it is estimated to at least 10^40 and 10^50 at most. Numbers of possible positions by plies is 20 after 1, 400 after 2, 5362 after 3, 72078 after 4, 822518 after 5, and 726155461002 after 11.
|
||||
|
||||
**Shortest possible checkmate** is by black on ply number 4 (so called *fool's mate*). As of 2022 the **longest known forced checkmate** is in 549 moves -- it has been discovered when computing the Lomonosov Tablebases.
|
||||
|
||||
Average game of chess lasts 40 moves. **Average [branching factor](branching_factor.md)** (number of possible moves at a time) is around 33. **Maximum number of possible moves in a position** seems to be 218 (FEN: `R6R/3Q4/1Q4Q1/4Q3/2Q4Q/Q4Q2/pp1Q4/kBNN1KB1 w - - 0 1`).
|
||||
|
||||
White wins about 38% of games, black wins about 34%, the remaining 28% are draws.
|
||||
|
||||
What is the **longest possible game**? It depends on the exact rules and details we set, for example if a 50 move rule applies, a player MAY claim a draw but also doesn't have to -- but if neither player ever claims a draw, a game can be played infinitely -- so we have to address details such as this. Nevertheless the longest possible chess game upon certain rules has been computed by [Tom7](tom7.md) at 17697 half moves in a paper for [SIGBOVIK](sigbovik.md) 2020. Chess programming wiki states 11798 half moves as the maximum length of a chess game which considers a 50 move rule (1966 publication).
|
||||
|
||||
The **longest game played in practice** is considered to be the one between Nikolic and Arsovic from 1989, a draw with 269 moves lasting over 20 hours. For a shortest game there have been ones with zero moves; serious decisive shortest game has occurred multiple times like this: `1.d4 Nf6 2.Bg5 c6 3.e3 Qa5+` (white resigned).
|
||||
|
||||
**Best player ever**: a 2017 paper called *Who is the Master?* analyzed 20 of the top players of history based on how good their moves were compared to Stockfish, the strongest engine. The resulting top 10 is (from best): Carlsen, Kramnik, Fischer, Kasparov, Anand, Khalifman, Smyslov, Petrosian, Karpov, Kasimdzhanov. It also confirmed that the quality of chess play at top level has been greatly increasing.
|
||||
|
||||
What's **the most typical game**? We can try to construct such a game from a game database by always picking the most common move in given position. Using the lichess database at the time of writing, we get the following incomplete game (the remainder of the game is split between four games, 2 won by white, 1 by black, 1 drawn):
|
||||
|
||||
```
|
||||
1. e4 e5 2. Nf3 Nc6 3. Bc4 Bc5 4. c3 Nf6 5. d4 exd4
|
||||
6. cxd4 Bb4+ 7. Nc3 Nxe4 8. O-O Bxc3 9. d5 Bf6 10. Re1 Ne7
|
||||
11. Rxe4 d6 12. Bg5 Bxg5 13. Nxg5 h6 14. Qe2 hxg5
|
||||
15. Re1 Be6 16. dxe6 f6 17. Re3 c6 18. Rh3 Rxh3
|
||||
19. gxh3 g6 20. Qf3 Qa5 21. Rd1 Qf5 22. Qb3 O-O-O
|
||||
23. Qa3 Qc5 24. Qb3 d5 25. Bf1
|
||||
```
|
||||
|
||||
You can try to derive your own stats, there are huge free game databases such as the Lichess [CC0](cc0.md) database of billions of games from their server.
|
||||
|
||||
## Variants
|
||||
|
||||
Besides similar games such as [shogi](shogi.md) there are many variants of chess, i.e. slight modifications of rules, foremost worth mentioning is for example chess 960. The following is a list of some variants:
|
||||
|
||||
- **antichess** ([suicide](suicide.md), ...): The goal is to lose all men or get stalemated, rules are a bit changed, e.g. castling and checks are removed and taking is forced.
|
||||
- **chess 960** aka **Fischer's random**: Starting position is randomly modified by shuffling the non-pawn rows (with these rules: king must be between rooks, bishops on opposite colors and black/white's positions are mirrored). The rules are the same with a slight modification to castling. This was invented by Bobby Fischer to emphasize pure chess skill as opposed to memorizing the best opening moves, he saw the opening theory as harmful to chess. Chess 960 is nowadays even advocated by some to become the "main" version of chess.
|
||||
- **[chess boxing](chess_boxing.md)**: Chess combined with box, players switch between the two games, one wins either by checkmate or knockout.
|
||||
- **crazyhouse**: When a player captures a man, it goes into his reserve. From the reserve a man can be dropped (as a man of the current player's color) to an empty square instead of making a normal move. This is a rule taken from [shogi](shogi.md).
|
||||
- **different men**: Some variants use different men, e.g. empress (moves like rook and knight) or amazon (queen/knight).
|
||||
- **duck chess**: After each move players place a duck on an empty square, the duck blocks the square. The duck cannot be left on the same square, it has to be moved. There are no checks, players win by capturing the king.
|
||||
- **fog of war**: Makes chess an incomplete-information game by allowing players to only see squares they can immediately move to (this is similarly to some strategy video games).
|
||||
- **horde chess**: Asymmetric starting position: large number of black pawns vs a white army of traditional men. Rules are slightly modified, e.g. black can only be defeated by having all pawns captured (there is no black king).
|
||||
- **infinite chess**: Infinite chessboard.
|
||||
- **minichess**: Smaller chessboard, e.g. 4x4, 4x8 etc. Los Alamos chess is played at 6x6 board without bishops (also no promotion to bishop, no pawn double step, no en passant, no castling). Some are already solved (e.g. 3x3).
|
||||
- **more players**: E.g. 3 man chess or 4 player chess allow more than two players to play, some use different boards.
|
||||
- **old chess**: The rules of chess itself have been changing over time (e.g. adding the 50 move rule etc.). The older rule sets can be seen as variants as well.
|
||||
- **puzzle**: For single player, chess positions are presented and the player has to find the best move or sequence of moves.
|
||||
- **racing kings**: The starting position has both players on the same side, the goal is to get one's king to the other side first.
|
||||
- **[non-Euclidean](non_euclidean.md)**: different geometries of the board, e.g. [hyperbolic](hyperbolic.md) or [spherical](spherical.md).
|
||||
- **3D chess**: [3D](3d.md) generalization of chess.
|
||||
- **randomly chosen variant**: Here a chess variant to be played is chosen at random before the game, e.g. by dice roll. { This is an idea I got, not sure if this exists or has a different name. ~drummyfish }
|
||||
|
||||
## Programming Chess
|
||||
### Programming Chess
|
||||
|
||||
NOTE: our [smallchesslib](smallchesslib.md)/smolchess engine is very simple, educational and can hopefully serve you as a nice study tool to start with :)
|
||||
|
||||
|
@ -140,6 +88,47 @@ Exhaustively searching the tree to great depths is not possible even with most p
|
|||
|
||||
Many other aspects come into the AI design such as opening books (databases of best opening moves), endgame tablebases (precomputed databases of winning moves in simple endgames), clock management, pondering (thinking on opponent's move), learning from played games etc. For details see the above linked chess programming wiki.
|
||||
|
||||
### Notable Chess Engines/Computers/Entities
|
||||
|
||||
TODO: table
|
||||
|
||||
## Stats And Records
|
||||
|
||||
Chess stats are pretty [interesting](interesting.md).
|
||||
|
||||
{ Some chess world records are here: https://timkr.home.xs4all.nl/records/records.htm. ~drummyfish }
|
||||
|
||||
**Number of possible games** is not known exactly, Shannon estimated it at 10^120 (lower bound, known as *Shannon number*). Number of possible games by plies played is 20 after 1, 400 after 2, 8902 after 3, 197281 after 4, 4865609 after 5, and 2015099950053364471960 after 15.
|
||||
|
||||
Similarly the **number of possibly reachable positions** (position for which so called *proof game* exists) is not known exactly, it is estimated to at least 10^40 and 10^50 at most. Numbers of possible positions by plies is 20 after 1, 400 after 2, 5362 after 3, 72078 after 4, 822518 after 5, and 726155461002 after 11.
|
||||
|
||||
**Shortest possible checkmate** is by black on ply number 4 (so called *fool's mate*). As of 2022 the **longest known forced checkmate** is in 549 moves -- it has been discovered when computing the Lomonosov Tablebases.
|
||||
|
||||
Average game of chess lasts 40 moves. **Average [branching factor](branching_factor.md)** (number of possible moves at a time) is around 33. **Maximum number of possible moves in a position** seems to be 218 (FEN: `R6R/3Q4/1Q4Q1/4Q3/2Q4Q/Q4Q2/pp1Q4/kBNN1KB1 w - - 0 1`).
|
||||
|
||||
White wins about 38% of games, black wins about 34%, the remaining 28% are draws (38.7%, 31.1%, 30.3% respectively on Computer Chess Rating Lists).
|
||||
|
||||
What is the **longest possible game**? It depends on the exact rules and details we set, for example if a 50 move rule applies, a player MAY claim a draw but also doesn't have to -- but if neither player ever claims a draw, a game can be played infinitely -- so we have to address details such as this. Nevertheless the longest possible chess game upon certain rules has been computed by [Tom7](tom7.md) at 17697 half moves in a paper for [SIGBOVIK](sigbovik.md) 2020. Chess programming wiki states 11798 half moves as the maximum length of a chess game which considers a 50 move rule (1966 publication).
|
||||
|
||||
The **longest game played in practice** is considered to be the one between Nikolic and Arsovic from 1989, a draw with 269 moves lasting over 20 hours. For a shortest game there have been ones with zero moves; serious decisive shortest game has occurred multiple times like this: `1.d4 Nf6 2.Bg5 c6 3.e3 Qa5+` (white resigned).
|
||||
|
||||
**Best player ever**: a 2017 paper called *Who is the Master?* analyzed 20 of the top players of history based on how good their moves were compared to Stockfish, the strongest engine. The resulting top 10 is (from best): Carlsen, Kramnik, Fischer, Kasparov, Anand, Khalifman, Smyslov, Petrosian, Karpov, Kasimdzhanov. It also confirmed that the quality of chess play at top level has been greatly increasing.
|
||||
|
||||
What's **the most typical game**? We can try to construct such a game from a game database by always picking the most common move in given position. Using the lichess database at the time of writing, we get the following incomplete game (the remainder of the game is split between four games, 2 won by white, 1 by black, 1 drawn):
|
||||
|
||||
```
|
||||
1. e4 e5 2. Nf3 Nc6 3. Bc4 Bc5 4. c3 Nf6 5. d4 exd4
|
||||
6. cxd4 Bb4+ 7. Nc3 Nxe4 8. O-O Bxc3 9. d5 Bf6 10. Re1 Ne7
|
||||
11. Rxe4 d6 12. Bg5 Bxg5 13. Nxg5 h6 14. Qe2 hxg5
|
||||
15. Re1 Be6 16. dxe6 f6 17. Re3 c6 18. Rh3 Rxh3
|
||||
19. gxh3 g6 20. Qf3 Qa5 21. Rd1 Qf5 22. Qb3 O-O-O
|
||||
23. Qa3 Qc5 24. Qb3 d5 25. Bf1
|
||||
```
|
||||
|
||||
You can try to derive your own stats, there are huge free game databases such as the Lichess [CC0](cc0.md) database of billions of games from their server.
|
||||
|
||||
{ TODO: Derive stats about the best move, i.e. for example "best move is usually by queen by three squares" or something like that. Could this actually help the play somehow? Maybe could be used for move ordering in alpha-beta. ~drummyfish }
|
||||
|
||||
## Rules
|
||||
|
||||
The exact rules of chess and their scope may depend on situation, this is just a sum up of rules generally used nowadays.
|
||||
|
@ -189,6 +178,28 @@ A player cannot make a move that would leave him in check!
|
|||
|
||||
Threefold repetition is a rule allowing a player to claim a draw if the same position (men positions, player's turn, castling rights, en passant state) occurs three times (not necessarily consecutively). The 50 move rule allows a player to claim a draw if no pawn has moved and no man has been captured in last 50 moves (both players making their move counts as a single move here).
|
||||
|
||||
### Variants
|
||||
|
||||
Besides similar games such as [shogi](shogi.md) there are many variants of chess, i.e. slight modifications of rules, foremost worth mentioning is for example chess 960. The following is a list of some variants:
|
||||
|
||||
- **antichess** ([suicide](suicide.md), ...): The goal is to lose all men or get stalemated, rules are a bit changed, e.g. castling and checks are removed and taking is forced.
|
||||
- **chess 960** aka **Fischer's random**: Starting position is randomly modified by shuffling the non-pawn rows (with these rules: king must be between rooks, bishops on opposite colors and black/white's positions are mirrored). The rules are the same with a slight modification to castling. This was invented by Bobby Fischer to emphasize pure chess skill as opposed to memorizing the best opening moves, he saw the opening theory as harmful to chess. Chess 960 is nowadays even advocated by some to become the "main" version of chess.
|
||||
- **[chess boxing](chess_boxing.md)**: Chess combined with box, players switch between the two games, one wins either by checkmate or knockout.
|
||||
- **crazyhouse**: When a player captures a man, it goes into his reserve. From the reserve a man can be dropped (as a man of the current player's color) to an empty square instead of making a normal move. This is a rule taken from [shogi](shogi.md).
|
||||
- **different men**: Some variants use different men, e.g. empress (moves like rook and knight) or amazon (queen/knight).
|
||||
- **duck chess**: After each move players place a duck on an empty square, the duck blocks the square. The duck cannot be left on the same square, it has to be moved. There are no checks, players win by capturing the king.
|
||||
- **fog of war**: Makes chess an incomplete-information game by allowing players to only see squares they can immediately move to (this is similarly to some strategy video games).
|
||||
- **horde chess**: Asymmetric starting position: large number of black pawns vs a white army of traditional men. Rules are slightly modified, e.g. black can only be defeated by having all pawns captured (there is no black king).
|
||||
- **infinite chess**: Infinite chessboard.
|
||||
- **minichess**: Smaller chessboard, e.g. 4x4, 4x8 etc. Los Alamos chess is played at 6x6 board without bishops (also no promotion to bishop, no pawn double step, no en passant, no castling). Some are already solved (e.g. 3x3).
|
||||
- **more players**: E.g. 3 man chess or 4 player chess allow more than two players to play, some use different boards.
|
||||
- **old chess**: The rules of chess itself have been changing over time (e.g. adding the 50 move rule etc.). The older rule sets can be seen as variants as well.
|
||||
- **puzzle**: For single player, chess positions are presented and the player has to find the best move or sequence of moves.
|
||||
- **racing kings**: The starting position has both players on the same side, the goal is to get one's king to the other side first.
|
||||
- **[non-Euclidean](non_euclidean.md)**: different geometries of the board, e.g. [hyperbolic](hyperbolic.md) or [spherical](spherical.md).
|
||||
- **3D chess**: [3D](3d.md) generalization of chess.
|
||||
- **randomly chosen variant**: Here a chess variant to be played is chosen at random before the game, e.g. by dice roll. { This is an idea I got, not sure if this exists or has a different name. ~drummyfish }
|
||||
|
||||
## Playing Tips
|
||||
|
||||
Some general tips and rules of thumb, mostly for beginners:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue