The score tables are the same for black and white as the bitboard just needs to be flipped to compute black’s score. The reason for having two distinct score tables is that the score bonus for the pieces is symmetrical upon the vertical axis but not for the pawns ( psqt.cpp ). This score bonus comes from two hardcoded square score tables: one for the pieces and one for the pawns. ![]() ![]() in the middle-game, the exposed black king on a5 is worth less than on g8 which is a safer square). For every square of the board, a score is assigned depending on the piece that occupies this square (e.g. This example will focus on a positional advantage criteria: having specific pieces on specific squares. Stockfish then computes a Phase factor ranging from 0 (game finished) to 128 (game not started), which helps to interpolate the between two different weightings. Hence, Stockfish has two weighting sets for every criteria: one for the middle-game and one for the end-game. For instance, a passed pawn might get more valuable in the late-game than in the middle-game. The weighting of the different criterias are different whether we are still in the opening, middle-game or end-game. This huge resulting evaluation function is actually calculated up to the 2nd order, to compute a bonus/malus based on the known attacking/defending status of the players.Ī lot of the pull requests in Stockfish GitHub repository consist of small changes in the weights of the aforementioned criterias, which lead to small ELO score improvements. King safety: attacked king, incoming checks, king in a ‘pieces shelter’, position of defenders.Space: squares controlled by all of your pieces.Passed pawns: blocked or unblocked passed pawns.Incoming threats: attacked pieces, hanging pieces, king threats, pawn push threats, discovered/slider attack threats, squares where your pieces could move but would get exchanged, weakly protected pieces.Strategical advantage for other pieces: pieces blocked, pieces on good outposts, bishop X-ray attacks, bishops on long diagonals, trapped pieces, exposed queen, infiltrated queen, rooks on open files, rooks and queen batteries, enemy king attacked.Strategical advantage for pawns: doubled pawns, isolated pawns, connected pawns, pawns supported by pieces, attacked pawns.Material advantage: strength of every piece, having a bishop pair.Positional advantage: having specific pieces on specific squares.Material imbalance: count of pieces for every player.The concepts and associated criterias are the following: However, what makes NNUE really unique are both its input encoding and its incremental calculation optimized for CPU evaluation.Ĭlassical evaluation in Stockfish, Image from Author In itself, the network is simple as it is made of 3 fully connected layers plus an output layer which can be expressed as material score. The network is trained using this dataset, and can be then fine-tuned using specific positions and evaluations. The basic idea for NNUE’s training is to build a huge input dataset of randomly generated positions which are evaluated at a low depth with classical Stockfish. ![]() This evaluation function will be optimized (training phase) in respect to the weight of its neurons, in order to output the most accurate evaluation when given known chess games. The goal of the network is to build an evaluation function which is a combination of the neurons from the different layers separated by non-linearities. Providing more information than needed in the encoding is called overspecialization, and allows to input more knowledge to the network in order to decrease its training cost.Changing player’s turn is also quicker as the inputs simply need to be flipped.Updating the inputs and subsequent neurons after a change in a position is quicker because this encoding allows incremental calculation, which is the strength of NNUE.Using this binary encoding instead of a simple “ Is piece X on square Y?” encoding (768 parameters) has several benefits: The input parameters of NNUE represent the following boolean value, iterated for every W, X, Y and Z: Is a king on a square X with a W piece Y on square Z ? NNUE does not understand bitboards and the position has to be encoded first. Architecture of NNUE, Image from Roman Zhukov, Stockfish NN Release (NNUE), Talkchess Input encoding
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |