Analysing a chess game at different positions

525 views

How do the engines and the players say if a side is winning or not? What are the key factors they consider while assigning a score to each side?

In: 0

18 Answers

Anonymous 0 Comments

If you want to see someone actually coding a (very simple) chess engine, I recommend [this Sebastian Lague video](https://www.youtube.com/watch?v=U4ogK0MIzqk).

You can exactly solve chess if you “think ahead”: Let’s say it’s white’s move:

– If white can immediately checkmate black’s king, say “white wins.”
– Check each legal move for white. If for each possible move, black can immediately checkmate white’s king next turn, say “black wins.”
– Check each legal move for white. Then for each move, check each of black’s possible responses. If, for each of black’s responses, white has a counter-response that immediately checkmates black’s king, say “white wins.”

Then you can look for a counter-counter-response to the counter-response, and so on.

In theory, all board positions are completely solvable this way. A good programmer can knock it out in a few weekends. But nobody’s going to want to wait a trillion years for the program to spit out the answer.

In practice, we have a limited amount of computer time and memory available.

So at some point, you have to “guess” who will win by “looking at the board” and doing some kind of “estimate” or “heuristic.” The simplest one (used by humans for a long time) is “material value,” as other posters have noted you assign points, pawn=1, knight/bishop=3, rook=5, queen=9. Add up the points, and you “guess” that whoever has the most points is winning.

Chess engine engineering is basically:

– (a) Find more efficient ways to represent boards / pieces / moves
– (b) Make better decisions about when to “stop thinking ahead” on one line so you can use the time to think further ahead on another line.
– (c) Figure out better heuristics for more accurately evaluating the board
– (d) Spend a lot of time pre-calculating what happens near the beginning and it’s not too overwhelming to “think ahead” through all the possibilities (“opening book” / “opening theory”)
– (e) Spend a lot of time pre-calculating what happens when there are only a few pieces and it’s not too overwhelming to exhaustively check all the possibilities (“endgame database” / “endgame theory”)

“Traditional” engines (e.g. Stockfish) program all this stuff directly.

AI chess engines (AlphaZero, Leela) are the same, but they mostly use AI for (c). [AI needs examples to learn from](https://www.youtube.com/watch?v=R9OHn5ZF4Uo), this is part of the reason why a lot of companies are collecting lots of user data, downloading vast amounts of Reddit posts, or asking humans to solve image recognition puzzles. But interestingly, if you’re making an AI-based chess engine, you actually don’t need a bunch of example games by human chess pros. It turns out that it works if you just have the AI generate its own examples by making it play against itself. It also turns out you don’t need (d) or (e) because the AI ends up learning all that stuff through experience on its own.

You are viewing 1 out of 18 answers, click here to view all answers.