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'd try to solve it at the python level (and by communicating with SF differently), as opposed to changing the SF code itself (try to make that your last attempt, as it's a rather difficult task). For a continuously improving evaluation you're probably better off using engine.analyse or an indefinite analysis which you keep monitoring. On a related note, you can also set the engine hash to larger ones(in MB).
    – user929304
    Feb 11, 2020 at 13:46

1 Answer 1


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:

  1. Find where Stockfish creates and uses the cache
  2. Modify the code to save the cache to disk when the game finishes
  3. 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
  • You're joking, right? There isn't one person in 50,000 that would know how to do this and get it to work correctly. Feb 11, 2020 at 17:54
  • @Bryan Towers. Thanks it is a little bit beyond me, but someone must have already made stockfish version vith hash saving capabilities (talkchess.com/forum3/…), so I might look into that.
    – Arturo
    Feb 12, 2020 at 4:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.