How does reverse analysis work?

Discussion of chess software programming and technical issues.

Moderators: bob, hgm, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
Post Reply
nnnnnnnn
Posts: 10
Joined: Mon Nov 18, 2019 1:36 pm
Full name: Mark Thellen

How does reverse analysis work?

Post by nnnnnnnn » Mon May 18, 2020 4:13 pm

I have seen "reverse analysis" of chess games in which the software analyzes a game by starting from the final moves and working backward. This presumably helps the hash table find refutations of earlier poor candidate moves. I have seen this both in analysis of Stockfish games (on fishcooking for example to help debug Stockfish) and in the "Analyze Game" feature on lichess.

My question is how the time control is implemented over UCI? How does the software controlling the reverse analysis know how much time to allocate to the engine to analyze a particular move? These analyses are very fast, how does the engine know when to allocate more time to a move exactly?

That is to say, suppose that U is a some UCI client controlling an engine E that is analyzing a game. What commands does U send to E to instruct E to reverse analyze the game?

Does U tell E that there is some specific time control for to make 40 moves in, if the game is 40 moves, and let the engine figure out the time?

Dann Corbit
Posts: 10756
Joined: Wed Mar 08, 2006 7:57 pm
Location: Redmond, WA USA
Contact:

Re: How does reverse analysis work?

Post by Dann Corbit » Mon May 18, 2020 4:39 pm

It is very simple.
It either replays a game backwards from the end to the start, or plays a list of EPD records backwards from the end to the start, analyzing as it goes.

Here is how to do it in Arena:
https://drive.google.com/open?id=17QvIs ... huiOnMYPBJ

Of course, you can be more creative, exploring various alternatives rather than a simple back to front.
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.

User avatar
hgm
Posts: 24441
Joined: Fri Mar 10, 2006 9:06 am
Location: Amsterdam
Full name: H G Muller
Contact:

Re: How does reverse analysis work?

Post by hgm » Mon May 18, 2020 5:41 pm

It is entirely up to the client how it does this. The simplest way (which I suppose almost everyone uses) would be to send the engine "go infinite" ('analyze mode'), and after a pretetermined time send it "stop". Then load the previous positions, and repeat. This way the client would be in full control of the timing. It can of course wait until it sees from the engine's PV infos that it has finished an iteration, or give extra time when the score is not stable enough from iteration to iteration.

An alternative would be to let the engine figure this out: set it for a time control where it has some freedom to allocate time, like with "go wtime 600000 btime 600000 movestogo 60", and wait for the engine to decide when it is time to stop thinking before you load it with the previous position.

nnnnnnnn
Posts: 10
Joined: Mon Nov 18, 2019 1:36 pm
Full name: Mark Thellen

Re: How does reverse analysis work?

Post by nnnnnnnn » Tue May 26, 2020 1:41 am

Does someone know where exactly in lichess the code to analyze a whole game (not just a position) is kept? I would like to look in detail at what parameters are going over UCI for lichess to analyze (i.e. to "blunder check") a whole game.

Post Reply