How to get stockfish to play a selfmatch without clearing the hash table between games A while ago I asked a question about how to let Stockfish play 10 games with itself for a limited number of moves:

Python script to let stockfish selfplay 10 games from a given position

This question was brilliantly answered by the user Phonon.

Now I would have a followup question. Since the games are starting from the same position, I would like to avoid to clean the hash memory, as I understand Stockfish does every time it starts a new game. Ideally, even the first game should avoid the hash table clearing since I might have analyzed the position before starting the self match and I would like to keep the information saved in the hash memory.

Is there a way to do that?

Thanks in advance.
I would like to keep the information saved in the hash memory. Is
  there a way to do that?


Yes, there is.

Stockfish is open source. So you can examine the code, modify it, recompile and rebuild.

What you need to do is:


Find where Stockfish creates and uses the cache
Modify the code to save the cache to disk when the game finishes
Modify the code to optionally (you won't want to do it for every new game) load the cache from disk for a new game