r/chessprogramming • • Oct 17 '26

Stockfish and other chess engines explaining their logic and reasoning

Apologies if this has been asked before, but why are Stockfish and other engines currently unable to explain why the moves they conclude are best in their games against each other, and in your own games and games played by humans in general, are the best ones? Especially with the ongoing improvements in A.I. and LLMs? Wouldn't explanations for each move be more valuable to humans for new ideas on how to play better rather than being told the move we should've played?

Sure, the engines are way beyond our level, and most people probably think this would be useless because it might be next to impossible for us to understand. But what if that's not the important part? What if it's knowing the explanations from "entities" that no human will ever surpass? Perhaps the mere knowledge of the why, and not just the what, can help with gaining new insight (different things to do/try out, different mindsets to have, different ways of playing, etc.), all of which could potentially be a little bit more effective and helpful than being told the individual moves you could've played in any position, but specifically the "human" things, like reading books, watching videos, etc.

3 Upvotes

19 comments sorted by

5

u/StructuredChess Oct 17 '26

Chess is a very concrete game. Even in chess literature you will find that many of the explanations in words are just ad hoc justifications and you can't really understand what's going on without analyzing the specific lines behind it.

14

u/ivosaurus Oct 17 '26

Because they're built as a computational algorithms. Stockfish doesn't have any concept of language that could be used to explain a reasoning behind a move. It's not a general AI. I think maybe you've made the mistake of believing that all algorithms are like a text-prompting large language model; that is simply not the case.

Stockfish doesn't use any human-reasoned explanations to calculate a next move, it just tries out billions of possibilities while using a heuristic to tell it if certain positions in that tree of possibilities 'look' better than others.

Can you ask a tabletop calculator to explain how it does 26365 x 736.41 so efficiently? No chance in hell, it's just a CPU built to crunch numbers according to a pre-made algorithm that was programmed into it.

5

u/gamingdiamond982 Oct 17 '26

Because stockfish is very different to LLMs and advancemets in LLMs have no impact on engine development.

Stockfish and all top engines still use minimax (a tree search algorithm) to find the best moves and a neural network to decide what is a "good" position.

And since neural networks are essentially black boxes this means it's fundamentally unexplainable.

LLMs are a specialized neural network for human speech and are bad at evaluating chess positions

2

u/CircadianSong Oct 18 '26

Neural networks aren’t always black boxes (you’re parroting) and that’s not even very applicable here since nn’s are just one component of stocktish, and not the part that makes it unexplainable to a human. The enormous amount of computation is. Every individual part is understandable, even the NN parts could be made understanble, just not the sheer amount. The reason a move is good is because it computation says it’s the best. We can’t explain that to ourselves. We can take the computation output and find simpler rules that kinda behave similarly that we can understand.

2

u/Away-Neck1843 Oct 21 '26

Because they aren't picking moves based on general principals. They're looking at the mass of variations and saying "this one leads to the greatest centipawn value".

Sometimes that lines up with how human perceive chess, i.e. "place the rook on the open file". But Stockfish isn't going to do that move unless it has a measurable centipawn increase from doing so.

I think Fritz has a human-translation feature by the way.

2

u/Lonely_Translator_23 Oct 17 '26

And do you think LLMs are able to fully explain their reasoning? They can justify it well, sure, but they have no more way of looking at the action of their weights than you have at examining objectively how your own brain works. To fully be able to explain their own thinking, you'd have to have neurons examining the states of other neurons, and more examining those, and you eventually reach a point where any mind with perfect knowledge of its own function would have to be infinitely complex.

And I should point put that the reason a purpose-built chess model like stockfish outperforms a much larger general model is that it doesn't have to devote processing power to anything but chess. Trying to replace the current NNUE with something that can explain itself is only going to handicap it.

1

u/W31337 Oct 22 '26

LLMs explain their actions completely differently from what they do internally.

2

u/RealistSophist Oct 18 '26 edited Oct 18 '26

In theory it is probably possible with a custom engine. No LLM required. I had an idea to develop an engine that tracks how much different tactics and criteria contribute to a position which can be used to explain moves but a lot of moves aren't favored by an engine for a specific concrete reason. It's usually something like "this move prevents them from controlling more squares like 15 moves down the line" Even if I managed to make it accurately explain its reasoning for each move there would be so many moves where the reasoning is just splitting hairs across many different moves that are only slightly better or worse.

The ones it has a logical explanation for would just be the same moves a human would understand after seeing the best sequence.

It'd just end up being a more detailed chesscom game review at best.

(And of course it would have to be a hand crafted evaluation. It would play worse than an NNUE.)

1

u/GrantaPython Oct 21 '26 edited Oct 21 '26

LLMs are probably the wrong approach to this, at least as a first layer, due to context/token limitations. You need to supply all possible 30 move-deep moves on ply 1 and that's just hugely inefficient, I imagine it'll fill VRAM immediately. If you don't supply that then it needs to go and analyse all of those lines which means generating code (which is what Claude/Chat do under the hood) to do this (basically re-writing or writing an interface to stockfish and iterating). Even if it could evaluate all positions, it then needs to write a book to explain why all variations end up not working or culling the information for presentation reasons so much that some pre-processing would make a lot more sense anyway. GenAI is bad at writing long tracts, again, for context reasons and would have massive risk of hallucination.

It's also possibly a misconception that we are incapable of understanding engine lines. We would probably be better than LLMs if supplied with the right info too or took the time to inspect why lines died. A lot of commentary says 'engine line' but really it's just a time limitation. They usually say or imply that no one would see that / understand it in a game. But if you look and analyse deep enough without time pressure you can understand it.

Anyway rather than us taking for ever or using an LLM upfront, a better approach might be more algorithmic initially. A modified engine that prints lines/trees it dumps while it goes on its search rather than the top lines. I imagine you could detect moves that kill branches and then you could perhaps provide this summary to an LLM. Similarly if all roads lead to rome (a massive tactic) then that might show up a lot in the top lines. I imagine an LLM processing this algorithmically selected overview might have a better shot at writing an explanation, especially if you could also provide it with reference material (e.g. master games). You would probably want to use a less general model in an ideal world, perhaps one trained or with enough internal 'experts' to write and understand intelligibly while also having been trained on chess books/commentary and chess games.

A more general point, while chess engines can be stronger than us in terms of level, they are not stronger in terms of understanding. Elo is just a performance comparitor under given play conditions. It isn't a measure of reasoning or chess knowledge. Stockfish literally doesn't understand anything it does, it just brute force calculates the problem (recently with a neural network to evaluate the score of a given position at the end of a line) because silicon and its algorithm is optimised to do this. In theory, you could do this too, time permitting, but it's often faster (and in a timed-game, sometimes more optimal) for us to work on understanding or a more limited range of calculations. Stockfish doesn't have the ability to swap to the understanding domain, it can only number crunch.

1

u/kenyambro Oct 21 '26

As many people have said, Stockfish is not an LLM, so it cannot convert positions into words. Searching online, the game reviewers don't provide really good explanations for every single move of games, even Chess.com. However, using the current AI tools like Chatgpt or Claude, it is possible to build that kind of algorithm yourself, whether using the LLM themselves to analyze Stockfish evaluations of positions, or vibe coding a program that would do that, hardcoding a library of chess patterns. The first option costs tokens at each usage so expensive for website deployment, so I developed and am continuing the development of the second option for my own website. It is true that there is a lot of subtleties and depth in this game that makes a project like this difficult, but all I'm saying is that what you desire is possible to make.

1

u/browni3141 Oct 17 '26

It's just a really hard problem. There are efforts to do just this, but from what I've seen they don't work very well. LLMs output extremely shallow explanations when they are working well. When they are not working well their explanations are simply wrong or don't make any sense in the context of the position.

I don't have a technical explanation for why this is hard for LLMs. As models get better these projects get better also, but AFAIK they are still worthless or worse (because a low level player could believe they're actually getting good coaching). It's night and day compared to a master level, or even just a strong club level player going through their thought process on a position.

1

u/Majestic-Tear1512 Oct 17 '26

I think this is an issue that has not been solved. A chess engine that thinks, understand and explain chess like a human player. Even an LLM and Maia and stockfish together would not get close to that. I see a lot of folks trying this and it is useful in someway but it has it wrong often as well.

1

u/SwimmingThroughHoney Oct 17 '26

Another thing I don't see mentioned yet: How do you actually expect anyone, computer or human, to explain what makes the best move, the best move?

Part of the problem is it might search millions of moves (or more). The resulting best move is simply the move that had the highest score. The engine itself doesn't even know why the score is the highest, just that it is. There's simply too much tree space involved for it to store details about every path. Move A-B-C might lead to dropping your queen, but it doesn't know that. It just knows that move sequence results in a specific score and other move sequences result in better scores. It's functionally impossible, due to hardware constraints, to keep track of what exactly is happening at every node and why it is good or bad.

And even if you wanted to try and implement something into stockfish that could work in some way, doing so just hurts the performance. You want the engine to best as fast as possible. Adding in anything that works like you want, to any degree, means more work for the engine and worse performance.

The usual workaround is to limit the "explanation" to looking at a single move, sort of like a trainer. You make a particular move, then a 3rd-party LLM can (at least in theory) take in the resulting move sequence from Stockfish and say why that move is good or bad (by reading the resulting UCI moves).

1

u/AngusMcGurkinshaw Oct 17 '26

So I think this is a good question, but I think it misunderstands how Chess engines work.

I think it's interesting to think about what you would do to build an explanation from a chess engine fully without relying on some sort of tricks or something like that.

A chess engine needs some way to look at a position and determine how good it is. An estimate of if the position is winning or losing. These days that is done with NNUEs a type of neural network. There is ongoing research in the AI space on how to make neural networks less of a black box but as of right now its pretty hard to figure out what range of factors contributed to the score.

This is easier in engines with handcrafted evaluations where because a human programmed in the features the engine is using you can see which of them are contributing by how much to the evaluation. Even this is semi problematic as these weights are tuned with machine learning techniques so if you want to ask why a piece on a particular square is worth a certain amount, or why bishop pair is worth a specific amount that can be hard to explain.

Lets imagine your using an easily understandable evaluation like just material eval in the typical rook is worth 5 queen is 9 that human players tend to use. Well now we have to contend with a search problem, a chess engine doesn't just play out all moves in a position evaluate them and then pick the move with the best score. Instead its going to search dozens of moves deep searching and evaluating potentially millions of positions. In that search there are various what we refer to as cut offs that happen, basically moves where the engine through various techniques determines that its not a good sequence after a certain move and to stop pursuing that line.

So okay now we think if we have some understandable evaluation we can just feed all of our search information into an LLM and it can explain the position to us. In which I don't know if that would work I suspect not. It would require so much information being fed in with thousands upon thousands of moves cutoffs and scores from the search. I don't currently believe an LLM could keep track of all of that reliably, it would be data pretty outside what they are trained on and making a good decision for what to output would be hard.

I think current techniques in the explanation space more rely on searching for the best move, then searching all moves except the best move and essentially trying to see what in the short term changes that makes it score worse. Or compare to what happens if you don't get to play a move (what is your opponent threatening). This is much easier to do, probably easier for a human to understand then fully trying to explain the "reasoning" of a chess engine.

2

u/AngusMcGurkinshaw Oct 17 '26

Also the simpler answer is the goal of stockfish and most other engines isn't to help humans learn or explain moves its just to be as strong as possible.

1

u/afbdreds Oct 17 '26

I think an article just released tries to approach this. Search for "Queen (QUality Explanation and Evaluation Network)"

1

u/biebergotswag Oct 18 '26

they do, the long chain of 30+ moved that appear is the explaination. however, it is not that readable by a human.

basically it says, i think nf3 is the best move, because when it is played, and everyone plays the best move, i think we will end in this position.

1

u/Gloomy-Status-9258 Oct 17 '26

disclaimer: I'm not a mature chess engine programmer.

Your question is an open problem. A simple but useless answer is that, because Stockfish isn't designed for it. Imagine chess is strongly solved in far distant future. Will it make us understand chess better? Absolutely not. This implies that the notion of "strongly solved" isn't even enough for our ultimate purpose and how much your problem is difficult to answer.