Free online Chess server. Play Chess now in a clean interface. No registration, no ads, no plugin required. Play Chess with the computer, friends or random opponents.
Sign in

Why does the computer analyse games in reverse?

Asked by EnragedViper
Tags stockfish engine chess engine question about analysis computer analysis analysis
Activity Viewed 1551 times, last updated
Just asked out of curiosity. You can see this in action by selecting any game that hasn't been analysed yet, clicking the "Request a computer analysis" button and watching as the graph get updated backwards from the end in real time - which is pretty neat, by the way. :)
But why is this done? Is it generally more efficient or more convenient to feed Stockfish the game in reverse? Is this a technique related to how to improve a chess engine's analysis of a game on the whole?
5 Answers
Answered by DoTheMath
"Analysis is streamed to you in real-time. From end to start, because it improves Stockfish's strength."
Also, I remember people suggesting Analysis should start from end, as it's more convenient to use that way.
Answered by AChessPlayer2016
I think it's done from end to start because it'll solve questions like:
What caused that checkmate?
What caused that stalemate?
What made the fork happen?
How did White lose a queen?
and others.
So, that's why it's better to analyze it backwards.
protectionfault commented :
I once built an engine so advanced, it refused to learn chess.
Answered by Classicler
Working backwards is a fundamental skill in humans. You first stumble on the effect and then go back to analyze why it happened (cause). I am pretty sure this was taught to you in math. When the teacher told you to check your work, you probably worked backwards to solve that problem. For example, if you we're checking the problem 5x18/9=10 to see if it is right, you would work backwards. The opposite of /9 is x9 so 10x9=90. Reverse x18 to get /18. Then 90/18=5. You end up with the number you started with.

Working backwards not only makes your solution accurate, it also applies cause and effect to whatever you are doing, including chess. For example, if you wanted to know why your opponent took your queen, go back a few moves. So there was Royal Fork on the last move. So how did that take place? Maybe it was because you moved your bishop to a square that enables you to attack a rook, but you missed the fact that when you move your bishop to that square, you leave the "Royal Fork square" undefended. So now, the enemy can take advantage of it. That is why 🐟 works backwards during analysis.
Answered by gwood
I think is just a convenient way to write the code. For example, if you wrote the evaluations code in the forward direction and wanted to work out the centipawn loss after the next move you would have to evaluate the best move from the current position and then the position after the move actually taken (i.e you have to evaluate the position twice. However, if you evaluate it in reverse you only would have to evaluate the current position and the previous one in the actual game. This sounds like two evaluations also but when you go back one further step you've already got the current evaluation from the previous step so you save yourself one evaluation.
Answered by BobC
I remember when it was changed to what it is now. Someone else can answer your questions better than I can. I agree it's "pretty neat". It makes it possible to start analyzing my games before the computer analysis is done.

Only registered members with one week of lichess activity can contribute to the Q&A.