How does the analysis engine score a position?

Sort:
metaxzen

When I analyze my games and the app gives me a very precise "black is -0.3" how is it calculating this score? 

blueemu

You can't really expect someone to explain the details of a chess engine's evaluation function in a forum post? It would take a large book (or a whole shelf of books) to cover the topic.

Rocky64

https://en.wikipedia.org/wiki/Computer_chess#Leaf_evaluation

blueemu
BuildingBlockhead wrote:

That's easy, it asks each of your pieces. But since you aren't allowed to talk during chess, you have to wait till after the game.

There actually WAS a chess program that worked that way. Each square on the board (64) and each piece and pawn (32) had its own processor core that ran evaluation functions, with another processor to manage them all.

flashlight002

@metaxzen the score you see is in centipawns or 100th of a pawn increments. So a score of +0.3 means that white, as a result of making this move is in a position as if it was ahead 0.3 of a pawn. If it said -0.30 it means that that the move has resulted in black being ahead 0.30 of a pawn.

Now you ask how does the engine get to these numbers? The engine being used is called Stockfish. Chess engines use an algorithm called a minimax algorithm that uses complex maths to assign a score to each move based on the engine's evaluation of that move at that point in the game by looking AHEAD to see the ramifications of making that move. It also looks at a whole bunch of factors in determining the score like who has more pieces on the board and what are those pieces, how safe is your king, are all your pieces protected? Or are there hanging pieces? Are there any backward pawns, doubled pawns or isolated pawns? Which side has the stronger position? Are you attacking? In addition it analyses all the possible moves you could make at that point, then all the moves based on each of those moves.....going deeper and deeper in its analysis. You will hear people talking about depth and plies. A ply is equivalent to 1 move by black or white. So a depth of 20 plies means the engine analysed 10 moves ahead for white and 10 moves ahead for black....and it is using the minimax algorithm all throughout its evaluation. However....our computers are not powerful enough to analyse every single possible permutation of moves, plus it would take forever to get a result happy.png!!! So it uses an additional set of instructions called alpha beta pruning. What this does is that the engine disregards moves it can see straight away are very very bad moves in its evaluation as it works deeper and deeper from the point you made your move.

That analysis going 20 plies deep looks like a tree of moves.....and you will hear people talking about a "move tree". The chess engine also has a database of known openings. It also has what is called a hash table, or transposition table. Have you often seen that you can get to the same position with pieces set out on the board in a particular way by more than one sequence of moves? E.g. 1.e4 e5 2. Nf3 Nc6 will look the same as 1.e4 Nc6. 2.Nf3 e5. In order to speed up the calculations and be more efficient the engine stores its evaluations as it computes and if it sees the same pattern like the example above it doesn't need to do a whole new analysis the second time it sees that position...it uses the initial calculation (even though the move sequence was different the end result on the board is the same....so it doesn't need to rethink things out for that position). There are many other settings and maths computations involved. But this is a very very basic idea of how a chess engine works to get to that no. You may also hear people talking about "nodes". A node is a position on the board. Chess engines work so fast they can evaluate many thousands of nodes a second! So they analyse many many positions to get to that figure you see! 

I hope this "short" explanation helps you understand that no you see when the engine gives your move or your opponent's move a score happy.png The other guy was right....there are books on how it all works and the guys who figured these engines out are mathematicians and computer science specialists. It is VERY INVOLVED AND COMPLEX. 

But the main thing is you understand what that no means.happy.png I hope you now do! 

Mate_In1

@metaxzen I was wondering the same thing.  Appreciated the answer by @flashlight002 but I was still curious about the details.  After more digging, I found this article that explains some of the evaluation algorithms, which is really pretty interesting happy.png

 

h ttps://chess24.com/en/read/news/how-do-chess-engines-think

drmrboss
Mate_In1 wrote:

@metaxzen I was wondering the same thing.  Appreciated the answer by @flashlight002 but I was still curious about the details.  After more digging, I found this article that explains some of the evaluation algorithms, which is really pretty interesting

 

h ttps://chess24.com/en/read/news/how-do-chess-engines-think

Those were dinosaurs time evaluation ( 3 years ago).Lol.

 

Current Stockfish evaluation is Neural Network ( SFNNUE or STOCKFISH 12).

Two types of evaluation 

1. Static evaluation  ( evaluation of current position )

2. Dynamic evaluation ( evaluation of the expected position at the end of certain depth, depth 10, depth 50 etc). 

For first evaluation,  you can put any position, choose Neural network,  and see which neurons activate for evaluation. 

https://hxim.github.io/Stockfish-Evaluation-Guide/

 

LeRoiDouteux

Woh. mind blown.