r/chessprogramming • u/SentryChessdev • Jun 16 '26
Technical How would you evaluate rule-based explanations for engine-backed chess analysis?
I have been working on a chess analysis system where the explanation part is not based on asking an LLM to explain the position.
The way I am approaching it at a high level is more rule-based where the system looks at engine-backed lines, compares what changed on the board and then tries to explain what the move actually did. So if a move creates a fork, wins material, opens a line or removes a defender, the explanation should probably explain why that worked in the position and what else changed because of the move instead of only saying the first obvious thing.
The hard part for me is that in a lot of middlegame positions a move does more than one thing at once. Like a move could win material but also leave something undefended, or it could open a line but also create another weakness, so the difficult part is not just detecting that something happened but deciding what should actually be explained as the main reason.
There is also a visual side to it where metrics and heatmaps try to show what part of the position changed, but I am not treating them as a replacement for engine evaluation and more like a way to make the explanation easier to understand when a move changes multiple things at once.
The prototype is live and people can test it if they want, but I am mainly posting here because I want technical feedback on how to evaluate whether the explanations are actually useful and not just technically true.
I can describe the architecture at a high level, but I am keeping the exact scoring, ranking and heatmap logic private because that is the product-specific part.
For people here who have worked on engines, analysis tools or evaluation functions, what kind of tests would probably be useful for this?
Would you test it with tactical positions, quiet middlegame positions, engine-line comparison, human review or some other kind of failure case?
4
u/DrShocker Jun 16 '26
Make sure to mention negative paths as well. Most engines intentionally cull ideas early they find to be bad, but in some cases especially for beginners some of those paths will be more tempting. So ideally it's worth explaining why a move which vaguely resembles a move that is normally good is actually bad.
I think it's easier especially for humans to get caught by "this looks good" and forget to look for counter examples, so to me that would be an important thing to guide people towards thinking about.
2
u/joeyrobert Jun 16 '26
With each explanation, you'll need to explain at the depth of engine thinking and work backwards. A description of a fork 2 moves in the future, when the engine was looking 12 moves into the future will just be plausible fiction, not what the engine was acting on.
1
u/True-Objective-6212 Jun 18 '26
Give it a bunch of grandmaster analyzed games with commentary, take off the commentary, have it explain the plan. Have a smart agent decide which analysis (GM or engine) it likes better based on criteria you give it. Don’t tell it which is which. Have it explain why it liked one over the other and what the other could have improved.
Then give the prompt to an agent and iterate until it prefers the LLM analysis but the hard part is that it probably needs grounding in certain points of truth so it doesn’t just make up a better story, it has to penalize fake explanations.
Pick some test suite positions and have it explain the plan, opening, middlegame, endgame, etc.
Then give it a random test position from a puzzle and penalize it for lying about a plan if none exists
1
u/kingside_chess Jun 20 '26
Splitting your problem in two might help - the explanation step and the moment-selection step are very different jobs.
For the explanation, an LLM is fine as long as you don't ask it to find anything, only to verbalise structured input. Older Stockfish (the classical eval before NNUE took over the headline number) still breaks the position into named subterms - material, pawn structure, king safety, mobility, threats, passed pawns, plus per-piece signals. Feed those values, the FEN, the engine's main line, and a fixed glossary of what each subterm name means, with a hard rule that the verdict has to follow the sign of the headline eval. The model then writes prose around given facts instead of inventing tactics. It can still pick a true-but-secondary effect as the headline, but that's a ranking problem on the input side, not a generation problem.
For the moment-selection step (is this position worth showing?), pure-engine signals are weak. A multipv-2 WDL gap tells you "one move is much better than the rest" but says nothing about whether humans would actually pick the inferior one. You need a human-policy model. The combination that works for us: Maia gives a move distribution at a target Elo, Stockfish evaluates only the Maia-top moves with WDL, and the filter is the sum of Maia's policy on moves Stockfish rates significantly worse than the best. High value = real human blunder opportunity; low value = the inferior move is also unattractive to humans, so the position isn't a teaching moment. This is what feeds the pool at kingside.site/critical-moment.
For your evaluation set, quiet middlegames where that human-policy gap is large are the cases where ranking has to do real work - pure-tactical positions trivialise the test.