]> git.sesse.net Git - stockfish/blob - README.md
Update UCI_Elo parameterization
[stockfish] / README.md
1 <div align="center">
2
3   [![Stockfish][stockfish128-logo]][website-link]
4
5   [![Build][build-badge]][build-link]
6   [![License][license-badge]][license-link]
7   <br>
8   [![Release][release-badge]][release-link]
9   [![Commits][commits-badge]][commits-link]
10   <br>
11   [![Website][website-badge]][website-link]
12   [![Fishtest][fishtest-badge]][fishtest-link]
13   [![Discord][discord-badge]][discord-link]
14
15 </div>
16
17 ## Overview
18
19 [Stockfish][website-link] is a free, powerful UCI chess engine derived from
20 Glaurung 2.1. Stockfish is not a complete chess program and requires a UCI-compatible
21 graphical user interface (GUI) (e.g. XBoard with PolyGlot, Scid, Cute Chess, eboard,
22 Arena, Sigma Chess, Shredder, Chess Partner or Fritz) in order to be used comfortably.
23 Read the documentation for your GUI of choice for information about how to use
24 Stockfish with it.
25
26 The Stockfish engine features two evaluation functions for chess. The efficiently
27 updatable neural network (NNUE) based evaluation is the default and by far the strongest.
28 The classical evaluation based on handcrafted terms remains available. The strongest
29 network is integrated in the binary and downloaded automatically during the build process.
30 The NNUE evaluation benefits from the vector intrinsics available on most CPUs (sse2,
31 avx2, neon, or similar).
32
33 ## Files
34
35 This distribution of Stockfish consists of the following files:
36
37   * [README.md][readme-link], the file you are currently reading.
38
39   * [Copying.txt][license-link], a text file containing the GNU General Public License
40     version 3.
41
42   * [AUTHORS][authors-link], a text file with the list of authors for the project.
43
44   * [src][src-link], a subdirectory containing the full source code, including a Makefile
45     that can be used to compile Stockfish on Unix-like systems.
46
47   * a file with the .nnue extension, storing the neural network for the NNUE evaluation.
48     Binary distributions will have this file embedded.
49
50 ## The UCI protocol and available options
51
52 The Universal Chess Interface (UCI) is a standard protocol used to communicate with
53 a chess engine, and is the recommended way to do so for typical graphical user interfaces
54 (GUI) or chess tools. Stockfish implements the majority of its options as described
55 in [the UCI protocol][uci-link].
56
57 Developers can see the default values for UCI options available in Stockfish by typing
58 `./stockfish uci` in a terminal, but the majority of users will typically see them and
59 change them via a chess GUI. This is a list of available UCI options in Stockfish:
60
61   * #### Threads
62     The number of CPU threads used for searching a position. For best performance, set
63     this equal to the number of CPU cores available.
64
65   * #### Hash
66     The size of the hash table in MB. It is recommended to set Hash after setting Threads.
67
68   * #### Clear Hash
69     Clear the hash table.
70
71   * #### Ponder
72     Let Stockfish ponder its next move while the opponent is thinking.
73
74   * #### MultiPV
75     Output the N best lines (principal variations, PVs) when searching.
76     Leave at 1 for best performance.
77
78   * #### Use NNUE
79     Toggle between the NNUE and classical evaluation functions. If set to "true",
80     the network parameters must be available to load from file (see also EvalFile),
81     if they are not embedded in the binary.
82
83   * #### EvalFile
84     The name of the file of the NNUE evaluation parameters. Depending on the GUI the
85     filename might have to include the full path to the folder/directory that contains
86     the file. Other locations, such as the directory that contains the binary and the
87     working directory, are also searched.
88
89   * #### UCI_AnalyseMode
90     An option handled by your GUI.
91
92   * #### UCI_Chess960
93     An option handled by your GUI. If true, Stockfish will play Chess960.
94
95   * #### UCI_ShowWDL
96     If enabled, show approximate WDL statistics as part of the engine output.
97     These WDL numbers model expected game outcomes for a given evaluation and
98     game ply for engine self-play at fishtest LTC conditions (60+0.6s per game).
99
100   * #### UCI_LimitStrength
101     Enable weaker play aiming for an Elo rating as set by UCI_Elo. This option overrides Skill Level.
102
103   * #### UCI_Elo
104     If enabled by UCI_LimitStrength, aim for an engine strength of the given Elo.
105     This Elo rating has been calibrated at a time control of 120s+1.0s and anchored to +- 100 Elo to CCRL Blitz.
106
107   * #### Skill Level
108     Lower the Skill Level in order to make Stockfish play weaker (see also UCI_LimitStrength).
109     Internally, MultiPV is enabled, and with a certain probability depending on the Skill Level a
110     weaker move will be played.
111
112   * #### SyzygyPath
113     Path to the folders/directories storing the Syzygy tablebase files. Multiple
114     directories are to be separated by ";" on Windows and by ":" on Unix-based
115     operating systems. Do not use spaces around the ";" or ":".
116
117     Example: `C:\tablebases\wdl345;C:\tablebases\wdl6;D:\tablebases\dtz345;D:\tablebases\dtz6`
118
119     It is recommended to store .rtbw files on an SSD. There is no loss in storing
120     the .rtbz files on a regular HDD. It is recommended to verify all md5 checksums
121     of the downloaded tablebase files (`md5sum -c checksum.md5`) as corruption will
122     lead to engine crashes.
123
124   * #### SyzygyProbeDepth
125     Minimum remaining search depth for which a position is probed. Set this option
126     to a higher value to probe less aggressively if you experience too much slowdown
127     (in terms of nps) due to tablebase probing.
128
129   * #### Syzygy50MoveRule
130     Disable to let fifty-move rule draws detected by Syzygy tablebase probes count
131     as wins or losses. This is useful for ICCF correspondence games.
132
133   * #### SyzygyProbeLimit
134     Limit Syzygy tablebase probing to positions with at most this many pieces left
135     (including kings and pawns).
136
137   * #### Move Overhead
138     Assume a time delay of x ms due to network and GUI overheads. This is useful to
139     avoid losses on time in those cases.
140
141   * #### Slow Mover
142     Lower values will make Stockfish take less time in games, higher values will
143     make it think longer.
144
145   * #### nodestime
146     Tells the engine to use nodes searched instead of wall time to account for
147     elapsed time. Useful for engine testing.
148
149   * #### Debug Log File
150     Write all communication to and from the engine into a text file.
151
152 For developers the following non-standard commands might be of interest, mainly useful for debugging:
153
154   * #### bench *ttSize threads limit fenFile limitType evalType*
155     Performs a standard benchmark using various options. The signature of a version
156     (standard node count) is obtained using all defaults. `bench` is currently
157     `bench 16 1 13 default depth mixed`.
158
159   * #### compiler
160     Give information about the compiler and environment used for building a binary.
161
162   * #### d
163     Display the current position, with ascii art and fen.
164
165   * #### eval
166     Return the evaluation of the current position.
167
168   * #### export_net [filename]
169     Exports the currently loaded network to a file.
170     If the currently loaded network is the embedded network and the filename
171     is not specified then the network is saved to the file matching the name
172     of the embedded network, as defined in evaluate.h.
173     If the currently loaded network is not the embedded network (some net set
174     through the UCI setoption) then the filename parameter is required and the
175     network is saved into that file.
176
177   * #### flip
178     Flips the side to move.
179
180
181 ## A note on classical evaluation versus NNUE evaluation
182
183 Both approaches assign a value to a position that is used in alpha-beta (PVS) search
184 to find the best move. The classical evaluation computes this value as a function
185 of various chess concepts, handcrafted by experts, tested and tuned using fishtest.
186 The NNUE evaluation computes this value with a neural network based on basic
187 inputs (e.g. piece positions only). The network is optimized and trained
188 on the evaluations of millions of positions at moderate search depth.
189
190 The NNUE evaluation was first introduced in shogi, and ported to Stockfish afterward.
191 It can be evaluated efficiently on CPUs, and exploits the fact that only parts
192 of the neural network need to be updated after a typical chess move.
193 [The nodchip repository][nodchip-link] provided the first version of the needed tools
194 to train and develop the NNUE networks. Today, more advanced training tools are
195 available in [the nnue-pytorch repository][pytorch-link], while data generation tools
196 are available in [a dedicated branch][tools-link].
197
198 On CPUs supporting modern vector instructions (avx2 and similar), the NNUE evaluation
199 results in much stronger playing strength, even if the nodes per second computed by
200 the engine is somewhat lower (roughly 80% of nps is typical).
201
202 Notes:
203
204 1) the NNUE evaluation depends on the Stockfish binary and the network parameter file
205 (see the EvalFile UCI option). Not every parameter file is compatible with a given
206 Stockfish binary, but the default value of the EvalFile UCI option is the name of a
207 network that is guaranteed to be compatible with that binary.
208
209 2) to use the NNUE evaluation, the additional data file with neural network parameters
210 needs to be available. Normally, this file is already embedded in the binary or it can
211 be downloaded. The filename for the default (recommended) net can be found as the default
212 value of the `EvalFile` UCI option, with the format `nn-[SHA256 first 12 digits].nnue`
213 (for instance, `nn-c157e0a5755b.nnue`). This file can be downloaded from
214 ```
215 https://tests.stockfishchess.org/api/nn/[filename]
216 ```
217 replacing `[filename]` as needed.
218
219 ## What to expect from the Syzygy tablebases?
220
221 If the engine is searching a position that is not in the tablebases (e.g.
222 a position with 8 pieces), it will access the tablebases during the search.
223 If the engine reports a very large score (typically 153.xx), this means
224 it has found a winning line into a tablebase position.
225
226 If the engine is given a position to search that is in the tablebases, it
227 will use the tablebases at the beginning of the search to preselect all
228 good moves, i.e. all moves that preserve the win or preserve the draw while
229 taking into account the 50-move rule.
230 It will then perform a search only on those moves. **The engine will not move
231 immediately**, unless there is only a single good move. **The engine likely
232 will not report a mate score, even if the position is known to be won.**
233
234 It is therefore clear that this behaviour is not identical to what one might
235 be used to with Nalimov tablebases. There are technical reasons for this
236 difference, the main technical reason being that Nalimov tablebases use the
237 DTM metric (distance-to-mate), while the Syzygy tablebases use a variation of the
238 DTZ metric (distance-to-zero, zero meaning any move that resets the 50-move
239 counter). This special metric is one of the reasons that the Syzygy tablebases are
240 more compact than Nalimov tablebases, while still storing all information
241 needed for optimal play and in addition being able to take into account
242 the 50-move rule.
243
244 ## Large Pages
245
246 Stockfish supports large pages on Linux and Windows. Large pages make
247 the hash access more efficient, improving the engine speed, especially
248 on large hash sizes. Typical increases are 5..10% in terms of nodes per
249 second, but speed increases up to 30% have been measured. The support is
250 automatic. Stockfish attempts to use large pages when available and
251 will fall back to regular memory allocation when this is not the case.
252
253 ### Support on Linux
254
255 Large page support on Linux is obtained by the Linux kernel
256 transparent huge pages functionality. Typically, transparent huge pages
257 are already enabled, and no configuration is needed.
258
259 ### Support on Windows
260
261 The use of large pages requires "Lock Pages in Memory" privilege. See
262 [Enable the Lock Pages in Memory Option (Windows)][lockpages-link]
263 on how to enable this privilege, then run [RAMMap][rammap-link]
264 to double-check that large pages are used. We suggest that you reboot
265 your computer after you have enabled large pages, because long Windows
266 sessions suffer from memory fragmentation, which may prevent Stockfish
267 from getting large pages: a fresh session is better in this regard.
268
269 ## Compiling Stockfish yourself from the sources
270
271 Stockfish has support for 32 or 64-bit CPUs, certain hardware
272 instructions, big-endian machines such as Power PC, and other platforms.
273
274 On Unix-like systems, it should be easy to compile Stockfish
275 directly from the source code with the included Makefile in the folder
276 `src`. In general it is recommended to run `make help` to see a list of make
277 targets with corresponding descriptions.
278
279 ```
280     cd src
281     make help
282     make net
283     make build ARCH=x86-64-modern
284 ```
285
286 When not using the Makefile to compile (for instance, with Microsoft MSVC) you
287 need to manually set/unset some switches in the compiler command line; see
288 file *types.h* for a quick reference.
289
290 When reporting an issue or a bug, please tell us which Stockfish version
291 and which compiler you used to create your executable. This information
292 can be found by typing the following command in a console:
293
294 ```
295     ./stockfish compiler
296 ```
297
298 ## Understanding the code base and participating in the project
299
300 Stockfish's improvement over the last decade has been a great community
301 effort. There are a few ways to help contribute to its growth.
302
303 ### Donating hardware
304
305 Improving Stockfish requires a massive amount of testing. You can donate
306 your hardware resources by installing the [Fishtest Worker][worker-link]
307 and view the current tests on [Fishtest][fishtest-link].
308
309 ### Improving the code
310
311 If you want to help improve the code, there are several valuable resources:
312
313 * [In this wiki,][programming-link] many techniques used in
314 Stockfish are explained with a lot of background information.
315
316 * [The section on Stockfish][programmingsf-link]
317 describes many features and techniques used by Stockfish. However, it is
318 generic rather than being focused on Stockfish's precise implementation.
319 Nevertheless, a helpful resource.
320
321 * The latest source can always be found on [GitHub][github-link].
322 Discussions about Stockfish take place these days mainly in the [FishCooking][fishcooking-link]
323 group and on the [Stockfish Discord channel][discord-link].
324 The engine testing is done on [Fishtest][fishtest-link].
325 If you want to help improve Stockfish, please read this [guideline][guideline-link]
326 first, where the basics of Stockfish development are explained.
327
328
329 ## Terms of use
330
331 Stockfish is free, and distributed under the **GNU General Public License version 3**
332 (GPL v3). Essentially, this means you are free to do almost exactly
333 what you want with the program, including distributing it among your
334 friends, making it available for download from your website, selling
335 it (either by itself or as part of some bigger software package), or
336 using it as the starting point for a software project of your own.
337
338 The only real limitation is that whenever you distribute Stockfish in
339 some way, you MUST always include the license and the full source code
340 (or a pointer to where the source code can be found) to generate the
341 exact binary you are distributing. If you make any changes to the
342 source code, these changes must also be made available under the GPL v3.
343
344 For full details, read the copy of the GPL v3 found in the file named
345 [*Copying.txt*][license-link].
346
347
348 [authors-link]:       https://github.com/official-stockfish/Stockfish/blob/master/AUTHORS
349 [build-link]:         https://github.com/official-stockfish/Stockfish/actions/workflows/stockfish.yml
350 [commits-link]:       https://github.com/official-stockfish/Stockfish/commits/master
351 [discord-link]:       https://discord.gg/GWDRS3kU6R
352 [fishcooking-link]:   https://groups.google.com/g/fishcooking
353 [fishtest-link]:      https://tests.stockfishchess.org/tests
354 [github-link]:        https://github.com/official-stockfish/Stockfish
355 [guideline-link]:     https://github.com/glinscott/fishtest/wiki/Creating-my-first-test
356 [license-link]:       https://github.com/official-stockfish/Stockfish/blob/master/Copying.txt
357 [lockpages-link]:     https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/enable-the-lock-pages-in-memory-option-windows
358 [nodchip-link]:       https://github.com/nodchip/Stockfish
359 [programming-link]:   https://www.chessprogramming.org/Main_Page
360 [programmingsf-link]: https://www.chessprogramming.org/Stockfish
361 [pytorch-link]:       https://github.com/glinscott/nnue-pytorch
362 [rammap-link]:        https://docs.microsoft.com/en-us/sysinternals/downloads/rammap
363 [readme-link]:        https://github.com/official-stockfish/Stockfish/blob/master/README.md
364 [release-link]:       https://github.com/official-stockfish/Stockfish/releases/latest
365 [src-link]:           https://github.com/official-stockfish/Stockfish/tree/master/src
366 [stockfish128-logo]:  https://stockfishchess.org/images/logo/icon_128x128.png
367 [tools-link]:         https://github.com/official-stockfish/Stockfish/tree/tools
368 [uci-link]:           https://www.shredderchess.com/download/div/uci.zip
369 [website-link]:       https://stockfishchess.org
370 [worker-link]:        https://github.com/glinscott/fishtest/wiki/Running-the-worker:-overview
371
372 [build-badge]:        https://img.shields.io/github/actions/workflow/status/official-stockfish/Stockfish/stockfish.yml?branch=master&style=for-the-badge&label=stockfish&logo=github
373 [commits-badge]:      https://img.shields.io/github/commits-since/official-stockfish/Stockfish/latest?style=for-the-badge
374 [discord-badge]:      https://img.shields.io/discord/435943710472011776?style=for-the-badge&label=discord&logo=Discord
375 [fishtest-badge]:     https://img.shields.io/website?style=for-the-badge&down_color=red&down_message=Offline&label=Fishtest&up_color=success&up_message=Online&url=https%3A%2F%2Ftests.stockfishchess.org%2Ftests%2Ffinished
376 [license-badge]:      https://img.shields.io/github/license/official-stockfish/Stockfish?style=for-the-badge&label=license&color=success
377 [release-badge]:      https://img.shields.io/github/v/release/official-stockfish/Stockfish?style=for-the-badge&label=official%20release
378 [website-badge]:      https://img.shields.io/website?style=for-the-badge&down_color=red&down_message=Offline&label=website&up_color=success&up_message=Online&url=https%3A%2F%2Fstockfishchess.org