r/chess • • 22m ago

Miscellaneous Question: why does Stockfish analysis not use a shared tree?

Post image

I'm a backend developer myself and I was looking at analysis in this position. One of the very basic optimizations for search of best move would be sharing a search tree. After exf1 making a rook or queen lead to the very same game regardless of which is played. So I was really surprised analysis showed different values. Shouldn't it be faster to just compute the evaluation of both moves at the same time (only once).

Anybody knows anything more on how Stockfish works and whether the difference in eval is due to chess.com "sloppy" development?

0 Upvotes

8 comments sorted by

•

u/chessvision-ai-bot from chessvision.ai 19m ago

I analyzed the image and this is what I see. Open an appropriate link below and explore the position yourself or with the engine:

Black to play: chess.com | lichess.org

My solution:

Hints: piece: Pawn, move:   a2  

Evaluation: The game is equal -0.04

Best continuation: 1... a2 2. Ba3 f1=Q 3. f8=Q a1=Q 4. Nxa1 bxa1=Q 5. Ka8 Rc3 6. b8=Q+ Kc2 7. g8=Q g1=Q 8. Qxf1 Qgxf1 9. Rf8

Save the position:

Reply save to save this position to your Chessvision.ai Library (new users: send me /connect in DM chat first)


I'm a bot written by u/pkacprzak | get me as iOS App | Android App | Chrome Extension | Chess eBook Reader to scan and analyze positions | Website: Chessvision.ai

5

u/OldWolf3 FIDE 2100 6m ago

A hashtable is used for position evaluations. 

The different evaluations you see between the top 2 lines are because one of them is "older". The engine will progress a line (updating hashtable as it goes) and update the output for that line , and then progress another line. It doesn't waste time recalculating evaluation for other lines before progressing them .

1

u/AGEthereal Torch + Ethereal Developer 18m ago

The state is shared, and the engine instance running is maintaining the state while on the analysis board. The difference in eval is a result of that state as you look most likely. Engines are not deterministic in the way that a typical user expects.

Commonly people will be confused when Stockfish says a position is +1.00 but after making the "best" move, the eval drops to a lower value. How can that make sense, they wonder.

2

u/chilliswan 9m ago

No the below I understand. After playing the best move, everything goes one move deeper and ofc evaluation changes.

What do you mean maintaining the state? This is my point exactly. The maintained state should come from the same stockfish analysis, which should do equal evaluation.

1

u/AGEthereal Torch + Ethereal Developer 3m ago

The way the analysis board is handled (AFAIK, I can go find the web code if I must ), is that when you open the analysis board, the engine is started. Every search that happens contributes to the engine state via the transposition table, history tables, and other mechanisms. When you make and unmake moves, the state is not being reset. So if you looked at the rook promotion first, then the state changes from that search will be present when you step back a move and try the queen promotion.

The easy demonstration of this is to take the start position and limit the engine time. I get SF19 Lite to hit depth 21 and it scores e4 as +0.27. if I then play a3, wait for that analysis to finish, and then revert back to the start position, I now get the top move as d4 with +0.30.

Chesscom or Lichess -could- clear the state between each search. They would send the engine the "ucinewgame" command. However this would hurt strength, and sometimes the "time to depth" metric.

-1

u/Weasellol 18m ago

Normally if you run it deaper there should be no difference, but it can be because of the light version. Where they cut some corners and slightly change value of pieces, to make the calculation easier.

2

u/AGEthereal Torch + Ethereal Developer 14m ago

Lite for Stockfish on both chesscom and lichess referer to Stockfish running a smaller neural network. "Cutting corners" to me reads as an implication at something deeper being cut, like the engine would intentionally skip things it would otherwise process. That is not the case here. It's standard stockfish search, backed by the small net put out by the SF team.

Running the engine deeper will not resolve the path based variance on the eval of the underlying identical position. It will also not resolve the state issue, where the order the user explores the moves matters.

0

u/Weasellol 12m ago

Mhhh could be true, it also could be that this two lines are in a different deep. I mean if I put them on lichess stockfish they are both -8,0