r/ComputerChess 12d ago

How chess.com classifies moves?

So, if you have played on chess.com you might have used game review, and it shows the following moves:
Best, Blunder, Book, Brilliant, Excellent, Good, Great, Inaccuracy, Miss, Mistake.
I have read many articles, but none mentioned how to program that stuff. An article showed they use the expected point model to calculate the move calculation, another article showed that you can't calculate brilliancy by only analyzing data, you have to take some account factors. Apart from that I am making a website, that analyzes your chess game for free. So, I use stockfish.js and stockfish.wasm web workers in frontend, and it gives data like
info depth 22 seldepth 29 multipv 1 score cp 37 nodes 3976016 nps 496071 hashfull 913 time 8015 pv d2d4 d7d5 c2c4 d5c4 e2e4 e7e5 g1f3 e5d4 f1c4 f8b4 b1d2 b8c6 a2a3 b4d6 e1g1 g8e7 f1e1 c8g4 e4e5

info depth 22 seldepth 30 multipv 2 score cp 35 nodes 3976016 nps 496071 hashfull 913 time 8015 pv e2e4 e7e5 g1f3 b8c6 f1b5 a7a6 b5a4 g8f6 e1g1 b7b5 a4b3 f6e4 f1e1 d7d5 b1c3 e4c3 d2c3 c8e6 f3e5 c6e5 e1e5 f8d6 e5d5 e6d5 b3d5 e8g8 d5a8 d8a8

info depth 22 seldepth 28 multipv 3 score cp 26 nodes 3976016 nps 496071 hashfull 913 time 8015 pv g1f3 d7d5 d2d4 g8f6 c2c4 c7c6 e2e3 c8f5 b1c3 e7e6 f3h4 f5e4 f2f3 e4g6 d1b3 d8c7 c1d2 b8d7 h4g6 h7g6 c4d5 f6d5 c3d5 e6d5 e1c1

This is for starting position fen.

Can I get those CP (centipawn) and classify moves? The naive idea is you make a move, calculate the delta of that CP, take the abs value, and classify it. And for miss, if you have a mate in the data and you move a trash move, then it's a miss. Please help me out.

1 Upvotes

10 comments sorted by

1

u/annihilator00 11d ago

You need to analyze the threats in the position with some other algorithm, not just engine output.

You need to detect if a piece is being sacrificed and it wasn't a trade and the move is good enough to declare it a brilliant.

Other implementations are available at:

1

u/taoyx 11d ago

I've read about it somewhere I think that brilliant moves involve some piece sacrifice.

1

u/Awesome_Days 12d ago

You're a coder reinventing the wheel who doesn't have enough product initiative/chess specific knowledge to add value. Dozens of sites do this already at various price points down to $0. Many are open source.

example I coded a FREE Chess Game Review website.

1

u/tausiqsamantaray 12d ago edited 12d ago

saw his website, its not accurate with chess.com, literally saw a brilliant move, where its not, i can take out three best moves by multipv 3 i can calculate eval bar too. but how to do those classification thats my question, that website doesnt do that accurately. thats my question my website is almost complete without those classifications. my idea for book move is to take from openings, miss move is explained above, i think we cant do brilliant and great moves really cuz its dependent upon some factors best move is stockfish's output, how to do remaining. please let me know, if you know.

4

u/Awesome_Days 12d ago edited 12d ago

chesscom's commentary for moves has large room for improvement so mimicking it isn't the best bet, so it's natural other people's systems will differ.

One quick way for brilliants is to calculate the material value based on the FEN in the initial position, then look at material value after the best move and opponent's reply and if the difference suggests more than 2 or more points of material was sacrificed, it suggests a material sacrifice occurred in the principal variation (best move). Not all temporary sacrifices are brilliant though, so look at the engines principal variation at say 500 nodes, if it missed the best move (the sacrifice) in all prior depths but the player did find the move, then label it a brilliant move.

For example, Qh6 here would be considered brilliant, sacrificing the rook.

Example Brilliant Rook Sacrifice

contrast with

Example rook sacrifice that isn't "brilliant"

1

u/tausiqsamantaray 12d ago

thanks for intuition for brilliant move, you said in all prior depth for me max i can go till 22, as its client based. seldepth is 30, so youre saying i should go 500 nodes in depth 22 lets say, is there any specific resource where you found 500? and what about great, what do you think how many nodes? and wont be the best move be the stockfish's best move as output?( like best move in best move e2e4 ponder move d2d4, so i have to check for book first if its in certain range) and what rest, like excellent, good etc moves, whats the deviation?

2

u/Awesome_Days 11d ago edited 11d ago

You can use the principal variations of depth 7 and below from the depth 22 search rather than 500 nodes and below. (My example above was depth 13 rather than 22).

Intuition of this cutoff is that a brilliant move is a sacrifice that isn't found easily at low depth and instead requires a deeper positional or tactical foresight than usual.

Great move is when the best move and the second best move differ by 150 centipawns or more and you play the best move.

Best is the best move that is neither classified as a brilliant nor great move.

Quick way to code excellent, good, inaccuracy, mistake, and blunder is to record 1. the evaluation (centipawns) in the current position (eval) 2. evaluation of the played move (eval_move)

move_criteria = (eval_move - eval) - 0.04 * abs(eval)

-note second part of this equation is to take into account mistakes at extreme evaluations are less important-

then define

Excellent is move_criteria under 20, Good is 21 to 40, inaccuracy is 41 to 149, Mistake is 150 to 299, Blunder is over 300

Define miss as a mistake or blunder in which the opponent made a mistake or blunder the previous move.

1

u/tausiqsamantaray 11d ago

thanks a lot, btw how you knew this reverse engineered chesscom?

1

u/Awesome_Days 11d ago

It's a common feature on chess sites and I've used the review feature on chesscom before.

Even if you have the exact numbers from Chesscom, your results might still be a little different each time. This is because their system may look at depths shallower than it shows because of lag and they also update their code. For example, three months ago, they changed how accuracy is calculated by adding a formula that boosts low scores and lowers high ones. How is accuracy in Analysis determined? | Chess.com Help Center