«победа сегфолтом» и другие эксплойты шахматных движков

The UCI protocol and available options

Developers can see the default values for UCI options available in Stockfish by typing
in a terminal, but the majority of users will typically see them and
change them via a chess GUI. This is a list of available UCI options in Stockfish:

  • The number of CPU threads used for searching a position. For best performance, set
    this equal to the number of CPU cores available.

  • The size of the hash table in MB. It is recommended to set Hash after setting Threads.

  • Clear the hash table.

  • Let Stockfish ponder its next move while the opponent is thinking.

  • Output the N best lines (principal variations, PVs) when searching.
    Leave at 1 for best performance.

  • Toggle between the NNUE and classical evaluation functions. If set to «true»,
    the network parameters must be available to load from file (see also EvalFile),
    if they are not embedded in the binary.

  • The name of the file of the NNUE evaluation parameters. Depending on the GUI the
    filename might have to include the full path to the folder/directory that contains the file.
    Other locations, such as the directory that contains the binary and the working directory,
    are also searched.

  • An option handled by your GUI.

  • An option handled by your GUI. If true, Stockfish will play Chess960.

  • If enabled, show approximate WDL statistics as part of the engine output.
    These WDL numbers model expected game outcomes for a given evaluation and
    game ply for engine self-play at fishtest LTC conditions (60+0.6s per game).

  • Enable weaker play aiming for an Elo rating as set by UCI_Elo. This option overrides Skill Level.

  • If enabled by UCI_LimitStrength, aim for an engine strength of the given Elo.
    This Elo rating has been calibrated at a time control of 60s+0.6s and anchored to CCRL 40/4.

  • Lower the Skill Level in order to make Stockfish play weaker (see also UCI_LimitStrength).
    Internally, MultiPV is enabled, and with a certain probability depending on the Skill Level a
    weaker move will be played.

  • SyzygyPath

    Path to the folders/directories storing the Syzygy tablebase files. Multiple
    directories are to be separated by «;» on Windows and by «:» on Unix-based
    operating systems. Do not use spaces around the «;» or «:».

    Example:

    It is recommended to store .rtbw files on an SSD. There is no loss in storing
    the .rtbz files on a regular HD. It is recommended to verify all md5 checksums
    of the downloaded tablebase files () as corruption will
    lead to engine crashes.

  • Minimum remaining search depth for which a position is probed. Set this option
    to a higher value to probe less aggressively if you experience too much slowdown
    (in terms of nps) due to tablebase probing.

  • Disable to let fifty-move rule draws detected by Syzygy tablebase probes count
    as wins or losses. This is useful for ICCF correspondence games.

  • Limit Syzygy tablebase probing to positions with at most this many pieces left
    (including kings and pawns).

  • Assume a time delay of x ms due to network and GUI overheads. This is useful to
    avoid losses on time in those cases.

  • Lower values will make Stockfish take less time in games, higher values will
    make it think longer.

  • Tells the engine to use nodes searched instead of wall time to account for
    elapsed time. Useful for engine testing.

  • Write all communication to and from the engine into a text file.

For developers the following non-standard commands might be of interest, mainly useful for debugging:

  • Performs a standard benchmark using various options. The signature of a version (standard node
    count) is obtained using all defaults. is currently .

  • Give information about the compiler and environment used for building a binary.

  • Display the current position, with ascii art and fen.

  • Return the evaluation of the current position.

  • Exports the currently loaded network to a file.
    If the currently loaded network is the embedded network and the filename
    is not specified then the network is saved to the file matching the name
    of the embedded network, as defined in evaluate.h.
    If the currently loaded network is not the embedded network (some net set
    through the UCI setoption) then the filename parameter is required and the
    network is saved into that file.

fishnet queuing

Server-side analysis requests on Lichess are appended to one of two queues: The “user queue”, for analysis requested by humans and the system queue for automated analysis (for example, as a first step to identify suspicious games for a closer look).

The user queue needs to be processed very quickly, because the user might be actively waiting for the result. The system queue is allowed to build some backlog at peak time, but should be cleared during the day.

Each fishnet client uses the queue status and an estimate of its own performance to see where it would be most useful. Consider a slow fishnet client with 1 core. If the user queue is normal, it will simply do system analysis and let faster clients handle the user queue. It will pick up work from the user queue only if it estimates that it can finish a game before a faster client has a chance to do so.

For the time being, fishnet batches always consist of complete games (with openings coming from stored cloud evaluations). So each analysed game can be attributed to a particular client.

Most games have more positions than the typical number of CPU cores, so some queuing is happening locally as well. For simplicity, the old Python client was putting available cores into groups, and then running mostly independent workers for each group. The diagram below shows an idealized scenario with an 8 core fishnet client analysing 2 short games of 11 and 20 positions. (In reality, not all positions will take equal time.) fishnet v2 lets each core individually pull from a local queue, which in turn pulls from the Lichess API, if empty. This change means that all analysis will finish much faster on average, without taking longer in the worst case.

You may notice that the last statement is not entirely true (especially with the switch to single-threaded analysis). A short game (like the orange one in the following diagram) can take slightly longer, if only a few positions remain for analysis in the final time step. This effect is negligible on longer games, and short games are … well … short anyway.

A note on classical evaluation versus NNUE evaluation

Both approaches assign a value to a position that is used in alpha-beta (PVS) search
to find the best move. The classical evaluation computes this value as a function
of various chess concepts, handcrafted by experts, tested and tuned using fishtest.
The NNUE evaluation computes this value with a neural network based on basic
inputs (e.g. piece positions only). The network is optimized and trained
on the evaluations of millions of positions at moderate search depth.

The NNUE evaluation was first introduced in shogi, and ported to Stockfish afterward.
It can be evaluated efficiently on CPUs, and exploits the fact that only parts
of the neural network need to be updated after a typical chess move.
The nodchip repository provides additional
tools to train and develop the NNUE networks. On CPUs supporting modern vector instructions
(avx2 and similar), the NNUE evaluation results in much stronger playing strength, even
if the nodes per second computed by the engine is somewhat lower (roughly 80% of nps
is typical).

Notes:

  1. the NNUE evaluation depends on the Stockfish binary and the network parameter
    file (see the EvalFile UCI option). Not every parameter file is compatible with a given
    Stockfish binary, but the default value of the EvalFile UCI option is the name of a network
    that is guaranteed to be compatible with that binary.

  2. to use the NNUE evaluation, the additional data file with neural network parameters
    needs to be available. Normally, this file is already embedded in the binary or it
    can be downloaded. The filename for the default (recommended) net can be found as the default
    value of the UCI option, with the format
    (for instance, ). This file can be downloaded from

replacing as needed.

Фиштест

С 2013 года Stockfish разрабатывается с использованием распределенной среды тестирования Fishtest , где добровольцы могут жертвовать процессорное время для тестирования улучшений программы.

Изменения в игровом коде принимаются или отклоняются на основании результатов прохождения десятков тысяч игр на платформе против более старой «эталонной» версии программы с использованием последовательного тестирования отношения вероятностей . Тесты на платформе проверяются с помощью теста хи-квадрат , и только если результаты статистически значимы, они считаются надежными и используются для корректировки программного кода.

По состоянию на июнь 2021 года фреймворк использовал в общей сложности более 5400 лет процессорного времени, чтобы сыграть более 3,1 миллиарда шахматных партий. После создания Fishtest всего за 12 месяцев Stockfish испытала взрывной рост на 120 баллов Эло , подняв его на вершину всех основных рейтинговых списков. В Stockfish 7 автор Fishtest Гэри Линскотт был добавлен в официальный список авторов в знак признания его вклада в силу Stockfish.

Terms of use

Stockfish is free, and distributed under the GNU General Public License version 3
(GPL v3). Essentially, this means you are free to do almost exactly
what you want with the program, including distributing it among your
friends, making it available for download from your website, selling
it (either by itself or as part of some bigger software package), or
using it as the starting point for a software project of your own.

The only real limitation is that whenever you distribute Stockfish in
some way, you MUST always include the full source code, or a pointer
to where the source code can be found, to generate the exact binary
you are distributing. If you make any changes to the source code,
these changes must also be made available under the GPL.

For full details, read the copy of the GPL v3 found in the file named
Copying.txt.

Stockfish 12

Among other improvements, Stockfish 12 brings a major new feature, NNUE (or ƎUИИ, for Efficiently Updatable Neural Network).  NNUE optionally replaces the handcrafted evaluation function with a neural network.

The main innovation is the ability to incrementally update the evaluation after moves, instead of evaluating the entire neural network from scratch. Stockfish remains a CPU based engine, and provides various build targets to progressively take advantage of modern vector instructions.

The following graph shows the strength improvements over the last Stockfish releases. SF_classical is the final development version before SF_NNUE landed. After the jump to SF_NNUE, some gains are specific to NNUE, others apply also to Stockfish with NNUE turned off.

Congratulations to all Stockfish contributors!

fishnet v2, rewritten in Rust

Server side analysis on Lichess is brought to you by fellow users who volunteer their CPU time using the fishnet client. fishnet started as a short and simple Python script that accumulated a lot of features over time.

To pay back technical debt, it has now been rewritten in Rust. Rust’s type and ownership system is amazing at catching issues at compile time, and it was refreshing to be able to confidently do major refactorings on concurrent code.

fishnet is using tokio for asynchronous communication with the Lichess API, a local queue, the engine processes, and the user who can stop the client at any time. Each of these are asynchronous tasks that talk over .

Being a systems programming language, Rust also has convenient access to and pick the best corresponding Stockfish build, rather than this , which uses ctypes to allocate executable memory and runs hardcoded machine instructions. This is important, because Stockfish 12 benefits immensely from the availability of vector instructions and brings a much wider array of possible target features.

Other improvements include:

  • fishnet now available for aarch64, with Stockfish built .
  • Will now use multi-variant Stockfish only for variant games or games with exotic material combinations, for a ~10% efficiency improvement.
  • The decision to value consistency and debuggability more than utmost efficiency. Your server-side analysis will now have consistent quality, no matter which client provided the analysis. This means using the smallest common denominator, which is 1 thread and small hashtables. It also means using NNUE even on old hardware. The next section explains how fishnet v2 delivers stronger analysis and does so more quickly, regardless.
  • Node targets are tuned to take the same time as Stockfish 11 on middle-aged x86-64-sse41-popcnt CPUs. (In this sense, 4,000,000 classical nodes appear to be equivalent to 2,250,000 NNUE nodes.) This calibration means you are actually getting a strength improvement out of this update, rather than just converting all gains into efficiency. Older CPUs (the minority) will take longer to reach the node target. Newer CPUs (the majority) are able to reach the node target more quickly.

Thanks to all fishnet contributors! If you are still running v1, you will hear from us soon, nudging you to upgrade. You can find instructions to upgrade or how to start contributing in the .

Функции

Stockfish может использовать до 512 потоков ЦП в многопроцессорных системах. Максимальный размер его таблицы транспонирования — 32 ТБ. Stockfish реализует расширенный альфа-бета-поиск и использует битовые доски . По сравнению с другими движками, он отличается большой глубиной поиска, отчасти из-за более агрессивной обрезки и позднего сокращения перемещений . По состоянию на сентябрь 2021 года Stockfish 14 (4-х ниточный) достигает рейтинга Эло 3550.+22 −22 на тесте CCRL 40/15.

Stockfish поддерживает Chess960 , что является одной из функций, унаследованных от Glaurung.

Поддержка Syzygy tablebase , ранее доступная в форке, поддерживаемом Рональдом де Маном, была интегрирована в Stockfish в 2014 году. В 2018 году была добавлена ​​поддержка Syzygy для 7 человек, вскоре после того, как она стала доступной.

История

Визуализация NNUE Stockfish

Программа возникла на основе Glaurung , шахматного движка с открытым исходным кодом, созданного Ромстадом и впервые выпущенного в 2004 году. Четыре года спустя Костальба, вдохновленный сильным движком с открытым исходным кодом, решил разделить проект. Он назвал его Stockfish, потому что он был «произведен в Норвегии и приготовлен в Италии» (Romstad — норвежский, Costalba — итальянский). Первая версия Stockfish 1.0 была выпущена в ноябре 2008 года. Некоторое время новые идеи и изменения кода передавались между двумя программами в обоих направлениях, пока Ромстад не решил прекратить выпуск Glaurung в пользу Stockfish, который был более продвинутым движком. в то время. Последний Glaurung (версия 2.2) был выпущен в декабре 2008 года.

Примерно в 2011 году Ромстад решил отказаться от участия в Stockfish, чтобы больше времени уделять своему новому шахматному приложению для iOS.

18 июня 2014 года Марко Костальба объявил, что «решил уйти с должности сопровождающего Stockfish», и попросил сообщество создать форк текущей версии и продолжить ее разработку. Официальный репозиторий, которым управляет группа добровольцев основных разработчиков Stockfish, был создан вскоре после этого и в настоящее время управляет развитием проекта.

В июне 2020 года разработчики обсудили форк эффективно обновляемой нейронной сети (NNUE), представленный компьютерными сёги- программистами под названием Stockfish NNUE. В июле 2020 года в новостях о шахматах сообщалось, что Stockfish NNUE «открыл новые возможности в компьютерных шахматах, включив нейронную сеть в и без того невероятно мощный шахматный движок Stockfish». Затем было объявлено о слиянии NNUE с Stockfish, и стали доступны сборки для разработки.

2 сентября 2020 года была выпущена двенадцатая версия Stockfish, включающая вышеупомянутое усовершенствование нейронной сети. Согласно объявлению в блоге, эта новая версия «играет значительно сильнее, чем любая из ее предшественников», обычно выигрывая в десять раз больше игр, чем проигрывает в сравнении с одиннадцатой версией.

ТОП-50 движков

Движок ЭЛО Игры Баллы Победы % Ничьи % Автор
 1  Stockfish 10 3551   27653  86.76 74.49 24.50 Romstad, Costalba, Kiiski, Linscott
 2  Houdini 6.02 3465   16240  80.81 64.08 33.40 Robert Houdart
 3  Komodo 12.3 3396   40000  73.93 56.79 34.30 Dailey, Kaufman,Lefler
 4  Fire 7.1 3354   30075  69.41 48.65 41.50 Norman Schmidt
 5  Xiphos 0.5 3319   19700  66.66 46.95 39.40 Milos Tatarevic
 6  Ethereal 11.25 3312   24470  65.33 44.07 42.50 Andrew Grant
 7  Laser 1.7 3274   22499  61.94 41.82 40.20 Jeffrey An, Michael An
 8  Shredder 13 3271   40771  63.93 42.05 43.80 Stefan Meyer-Kahlen
 9  Booot 6.3.1 3251   17406  53.43 27.02 52.80 Alex Morozov
 10  Andscacs 0.95 3239   25722  58.23 37.85 40.80 Daniel Jose Queralto
 11  Fizbo 2.0 3233   33983  56.74 37.79 37.90 Youri Matiounine
 12  Gull 3 3194   35168  58.29 37.03 42.50 Vadim Demichev
 13  Schooner 2.0.34 3169   20336  50.21 30.56 39.30 Dennis Sceviour
 14  Fritz 16 3159   21943  52.16 31.90 40.50 Chessbase
 15  Equinox 3.30 3152   27196  54.86 33.39 42.90 Colli, Rocchi
 16  Chiron 4 3150   27433  51.62 29.90 43.40 Ubaldo Andrea Farina
 17  Critter 1.6a 3145   32304  53.61 32.41 42.40 Richard Vida
 18  Rofchade 2.0 3132   21250  47.47 27.60 39.70 Ronald Friedrich
 19  Nirvana 2.4 3117   25259  49.34 28.89 40.90 Thomas Kolarik
 20  Pedone 1.9 3108   18902  45.14 26.15 38.00 Fabio Gobbato
 21  Texel 1.07 3098   23670  47.34 29.07 36.60 Peter Osterlund
 22  Hannibal 1.7 3094   27263  46.92 26.74 40.40 Sam Hamilton, Edsel Apostol
 23  Nemorino 5.00 3093   20484  45.13 27.39 35.50 Christian Gunther
 24  Senpai 2.0 3074   22396  44.15 25.30 37.70 Fabien Letouzey
 25  Protector 1.9.0 3062   25684  45.86 25.95 39.80 Raimund Heid
 26  iCE 3.0 3058   21805  46.82 28.75 36.10 Thomas Petzke
 27  Vajolet 2.2.6 3058   15110  42.40 22.90 39.00 Marco Belli
 28  Chess22k 1.12 3048   16377  38.13 20.19 35.90 Sander Maassen vd Brink
 29  Arasan 21.3 3043   2700  33.91 18.56 30.70 Jon Dart
 30  Wasp 3.50 3030   20812  39.01 21.12 35.80 John Stanback
 31  Smarthink 1.98 3030   16979  42.61 28.40 28.40 Sergei Markoff
 32  SCTR 1.1f 3000   4990  36.44 19.58 33.70 Can Catin, Dogac Eidenk
 33  Naum 4.6 3000   25742  39.35 21.53 35.60 Aleksandar Naumov
 34  Demolito 2018-10-29 2980   17426  35.54 20.34 30.40 Lucas Braesch
 35  ChessBrainVB 3.70 2980   2113  51.16 32.23 37.90 Roger Zuehlsdorf
 36  Pirarucu 2.9.5 2979   12248  38.33 22.14 32.40 Raoni Campos
 37  Rodent III 0.273 2949   12901  35.83 19.89 31.90 Pablo Vazquez, Pawel Koziol
 38  Deuterium 2019.1.36.50 2947   16266  31.24 15.90 30.70 Ferdinand Mosca
 39  HIARCS 14 2940   19029  36.52 20.69 31.70 Mark Uniacke
 40  Bobcat 8.0 2929   16544  32.41 16.95 30.90 Gunnar Harms
 41  Hakkapeliitta 3.0 2928   14833  34.14 21.15 26.00 Mikko Aarnos
 42  Alfil 15.8 2926   777  45.37 25.10 40.50 Enrique Sanchez Acosta
 43  Amoeba 2.8 2905   13761  31.57 16.74 29.70 Richard Delorme
 44  Crafty 25.2 2894   14925  29.65 16.42 26.50 Bob Hyatt
 45  Dirty Cucumber 2892   2134  43.09 25.68 34.80 Kannan, Valverde, Bluemers
 46  Cheng 4.39 2891   17575  30.77 16.12 29.30 Martin Sedlak
 47  Spark 1.0 2884   18551  31.44 16.28 30.30 Allard Siemelink
 48  Sjeng 2010 2880   17481  30.08 16.08 28.00 Gian-Carlo Pascutto
 49  Spike 1.4 2868   19773  29.50 15.27 28.50 Volker Bohm, Ralf Schafer
 50  Atlas 3.91 2862   12107  25.58 13.70 23.70 Andres Manzanares Campillo

Compiling Stockfish yourself from the sources

Stockfish has support for 32 or 64-bit CPUs, certain hardware
instructions, big-endian machines such as Power PC, and other platforms.

On Unix-like systems, it should be easy to compile Stockfish
directly from the source code with the included Makefile in the folder
. In general it is recommended to run to see a list of make
targets with corresponding descriptions.

When not using the Makefile to compile (for instance, with Microsoft MSVC) you
need to manually set/unset some switches in the compiler command line; see
file types.h for a quick reference.

When reporting an issue or a bug, please tell us which Stockfish version
and which compiler you used to create your executable. This information
can be found by typing the following command in a console:

Stockfish 12 in WebAssembly

Lichess maintains a fork of Stockfish with WebAssembly support, but Stockfish 12 NNUE is not quite ready for the web.

A small obstacle is that the compressed neural network file is about 10MB. For comparison, all of Lichess’s compressed client side assets of all pages, JavaScript, CSS, all board themes, all 2d and 3d piece themes, and all sound sets, sum to 35MB, a figure that we try hard to keep low.

Time will show how much the Elo gap between NNUE and Classical eval increases, and what appears to be the best tradeoff for client side analysis.

More importantly, the WASM build of Stockfish 12 NNUE appears to be inexplicably slow, even considering the absence of vector instructions in WebAssembly. In some sense this might be good news. Maybe the slowness is due to a bug or oversight that can be easily fixed once found, rather than a more fundamental issue. Experimental WASM SIMD gives a speedup, but it is insufficient, given the bad base performance. If you know your way around C++, emscripten and WebAssembly, tackling this issue would be an amazing contribution. The last attempt can be found in this pull request, which is simply stockfish.wasm with a hack to make the EvalFile available in memory.

Nonetheless, Stockfish 12+ delivers considerable improvements even with NNUE turned off, so let’s withhold it no longer! We have updated the client side engine to the strongest available build. We have also taken this opportunity, to once again remember the Stockfish toggle state (at least per tab/session).

What to expect from the Syzygy tablebases?

If the engine is searching a position that is not in the tablebases (e.g.
a position with 8 pieces), it will access the tablebases during the search.
If the engine reports a very large score (typically 153.xx), this means
it has found a winning line into a tablebase position.

If the engine is given a position to search that is in the tablebases, it
will use the tablebases at the beginning of the search to preselect all
good moves, i.e. all moves that preserve the win or preserve the draw while
taking into account the 50-move rule.
It will then perform a search only on those moves. The engine will not move
immediately, unless there is only a single good move. The engine likely
will not report a mate score, even if the position is known to be won.

It is therefore clear that this behaviour is not identical to what one might
be used to with Nalimov tablebases. There are technical reasons for this
difference, the main technical reason being that Nalimov tablebases use the
DTM metric (distance-to-mate), while the Syzygy tablebases use a variation of the
DTZ metric (distance-to-zero, zero meaning any move that resets the 50-move
counter). This special metric is one of the reasons that the Syzygy tablebases are
more compact than Nalimov tablebases, while still storing all information
needed for optimal play and in addition being able to take into account
the 50-move rule.

Платформы

Релизные и разрабатываемые версии доступны как исходный код C ++ и как предварительно скомпилированные версии для Microsoft Windows , macOS , 32-разрядной / 64-разрядной версии Linux и Android .

Stockfish был очень популярным движком на различных платформах. На настольных компьютерах это шахматный движок по умолчанию, связанный с интерфейсными программами интернет-шахматного клуба BlitzIn и Dasher. На мобильных устройствах он поставляется в комплекте с приложением Stockfish, SmallFish и Droidfish. Другие графические пользовательские интерфейсы, совместимые со Stockfish, включают Fritz , Arena, Stockfish для Mac и PyChess . По состоянию на март 2014 года Stockfish — это шахматный движок, используемый Lichess , популярным шахматным онлайн-сайтом.

Stockfish можно скомпилировать в WebAssembly или JavaScript , что позволит запускать его в браузере. И Chess.com, и Lichess предоставляют Stockfish в этой форме в дополнение к серверной программе.

Large Pages

Stockfish supports large pages on Linux and Windows. Large pages make
the hash access more efficient, improving the engine speed, especially
on large hash sizes. Typical increases are 5..10% in terms of nodes per
second, but speed increases up to 30% have been measured. The support is
automatic. Stockfish attempts to use large pages when available and
will fall back to regular memory allocation when this is not the case.

Support on Linux

Large page support on Linux is obtained by the Linux kernel
transparent huge pages functionality. Typically, transparent huge pages
are already enabled, and no configuration is needed.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *

Adblock
detector