When to use Clear Hash I am developing a program that analyzes games sequentially, i.e. one game after another.

Below are the parameters.



Engine: Stockfish 10

Threads: 2

Hash Table: 4000

Depth: 30



My question is about when to use the command: "setoption name Clear Hash."

Should it be used after each position is analysed? This means that each position would have a "fresh" hash at the beginning of the analysis.

Or should it be used after each game is analysed? What are the differences?
If your goal is to get the highest quality of analysis, then the short answer is "never".

The reason is that if you analyze similar positions within a game, then the existing hash table entries can still be valuable for move ordering and evaluation, because the same positions might be encountered somewhere in the search tree again.

If you switch to a new game, then the hash should be cleared, but in that case Stockfish already does it implicitly when it receives the ucinewgame command. In fact, in Stockfish ucinewgame does exactly the same as setoption name Clear Hash.