Stockfish

Jatin Madan
7 min readDec 18, 2022

--

By Akhilesh Dongre, Jatin Madan, & Sreya Vallabhaneni

Introduction

“Inevitably the machines must win, but there is still a long way to go before a human on his or her best day is unable to defeat the best computer.”

-Garry Kasparov

The world watched in disbelief in 1997 as GM Garry Kasparov, regarded as the greatest chess player yet, lost to a computer. The emergence of chess engines has forever altered the level of competition.

A chess engine is a computer program that analyzes chess or chess variant positions and generates a move or list of moves that it regards as the strongest.

Even better, as processing power has grown, chess engines have become much better at playing the game. This is because calculations can now be done in real-time at deeper and deeper levels.

Chess.com, for instance, allows users to play against computer personalities using the Komodo engine and uses Stockfish on the analysis board. Amongst all the available chess engines, Stockfish is the strongest chess engine (Stockfish 13 — Elo 3546)

What is Stockfish?

The strongest publicly accessible chess engine is and has been, Stockfish. It is a free, open-source engine that is actively being developed by a large community. Stockfish was built on a chess engine that Tord Romstad made in 2004 and that Marco Costalba improved in 2008. Gary Linscott and Joona Kiiski are likewise regarded as founders.

Stockfish

At the moment, Stockfish 13 64-bit 4CPU has an Elo rating of an incredible 3546 points.

How does it work?

Alpha-beta pruning is the search algorithm used by stockfish. Minimax search is made better by alpha-beta pruning, which avoids variations that will never be reached in optimal play because either side would change the course of the game.

When the search gets to a certain depth, it is stopped early because it is usually not efficient to keep searching until the end of the game. A player’s turn, or ply, which represents search depth, is one ply.

When the search depth is D, the search tree’s root node and leaf nodes are separated by D plys. Iterative deepening is the mechanism by which a stockfish gradually deepens its search tree. The search may not have considered all-D move variations, even though chess engines may offer a nominal search depth of D. This happens because, according to heuristics, the engine looks for promising variations more deeply than it needs to and less deeply than it needs to for less promising variations.

Stockfish uses two main types of heuristics, called forward pruning and reduction, to narrow the search space.

Using the forward pruning approach, subgraphs of the game tree not expected to be present during ideal play are pruned. The engine could accidentally prune a line of play. Once the engine depth exceeds a depth cap1 that is particular to the technique, this will be fixed, and the technique will no longer be used.

Reduction techniques Instead of completely excluding some game tree subgraphs from the search, search them at lower depths. Late move reductions, which presumptively check better moves earlier in the engine’s check cycle, are a canonical example. Subsequent moves are searched for at shallower depths than usual.

The engine will reach the ideal play if given infinite time. By pruning, depth limitations make sure that no lines are missed, and at infinite depth, reductions don't matter.

What is depth in stockfish?

The depth value in chess engine analysis describes how many half-movements (moves made by only one side) the engine predicts. Larger depth values are often linked to better analysis results, but many other factors come into play.

Stockfish makes an extremely basic assessment of a large tree of potential outcomes. The movements that receive low scores are subsequently pruned (cut off), and further analysis is done on the moves that remain. Stockfish keeps going through the process until just a handful of the finest possibilities remain.

Evaluation

After the search algorithm gets to a leaf node, a heuristic evaluation function is used to figure out if the ending position is better for White or Black. This function is hard-coded in Stockfish versions 11 and earlier, using chess notions like piece location, piece activity, and game phase (opening, middle, or endgame).

Nasu (2018) made the efficiently updatable neural network evaluation (NNUE) algorithm for the Japanese version of chess called Shogi. Stockfish implemented it for their chess engine in version 12 (Stockfish Team, 2020).

Neural network architecture: without a graphics processor, this neural network analyzes a game position on a CPU. Stockfish’s wide contributor base continues to allow for simple integration with a variety of devices and customization.

The architecture of NNUE, Image from Roman Zhukov, Stockfish NN Release (NNUE), Talkchess

The fundamental concept behind NNUE training is to create a sizable input dataset of randomly generated locations that are then assessed with traditional stockfish at a shallow depth. This dataset is used to train the network, which may then be adjusted using certain positions and assessments. The network is easy to understand on its own because it has three layers that are all connected and an output layer that can be used to show material scores.

Stockfish still uses classic evaluation, except for exceptionally balanced positions.

Classical Evaluation: The goal is to make an evaluation function that combines chess ideas and is made up of differently weighted criteria that are added together. Then, by scaling this function, a material advantage can be demonstrated in standard pawn units.

The massive evaluation function is run up to the second order to determine whether a player should receive a bonus or a penalty based on whether they are attacking or defending.

Stockfish offers two weighting sets for each criterion: one for the middle game and one for the end game. Stockfish then calculates a phase factor to interpolate between two different weightings, ranging from 0 (game done) to 128 (game not started).

The assessment is then scaled up one more to match the fifty-move rule, and when this rule is almost achieved, a draw is becoming more likely.

NNUE is almost twice as sluggish as Stockfish’s standard evaluation function; however, the engine makes up for this in evaluation quality.

How is Stockfish different from other chess engines?

The accomplishments of Stockfish surpass those of every other chess engine. Through 2020, it has won eight Top Chess Engine Championships (TCEC). Since 2018, Stockfish has also dominated Chess.com’s Computer Chess Championship, taking first place in all but one of the competition’s editions.

When tasked with solving Plaskett’s puzzle, Stockfish’s approach proved superior. The engine searched through nearly 1.9 billion distinct positions to identify the optimal solution. Due in part to domain-specific search optimizations, the algorithm was so efficient that it was able to find the surprising, unlikely solution.

The CCC 16 Bullet, Blitz, and Rapid, the CCC 960 Championship, and the CCC 17 Rapid were all won by Stockfish. Stockfish won Season 21, Cup 9, FRC 4, and the Season 22 super final at TCEC. As of this writing, he has won 16 game pairs and has not yet lost one in the current season's 22-game super final.

The only engine with a rating higher than 3500 as of October 2020 is Stockfish, which has a rating of 3514 according to the Computer Chess Rating List (CCRL). Stockfish 9 is ranked third, Stockfish 10 is ranked second, and Stockfish 11 is placed first with a rating of 3558 in the July 2020 Swedish Chess Computer Association (SSDF) rating list. It is quite remarkable to have the top three rankings in three distinct versions.

Conclusion

The Stockfish engine’s brilliance is built into its search. Our research suggests that Stockfish could now be the superior tool for deciphering complex problems for end users. A chess studies dataset should be developed and utilized as a standard for contemporary chess engines to verify this idea.

Copyright 2022 Akhilesh Dongre, Jatin Madan, Sreya Vallabhaneni

Permission is hereby granted, free of charge, to any person obtaining a copy of this article and associated documentation files, to deal in the article without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the article, and to permit persons to whom the article is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the article.

THE ARTICLE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE ARTICLE OR THE USE OR OTHER DEALINGS IN THE ARTICLE.

--

--