0

I am using a UCI chess engine (stockfish 6) to evaluate the score of specific positions from different games.

On this stockfish help forum thread it states: Hash size is the amount of memory you want to designate for Stockfish to store positions (a temporary hash). You don't want your hash size to exceed your physical memory, but you don't want it to be too small either.

In my case I am not using the engine to go through subsequent moves in the same game, but different positions entirely. For example:

after 4th move of Aldrovandi vs. Cocozza (2003):

position fen rnbqkbnr/pppp2pp/8/4pp2/8/5P2/PPPPPKPP/RNBQ1BNR w kq f6 0 3
go movetime 10000
info depth 16 seldepth 25 multipv 1 score cp -71 nodes 2171367 nps 879095 tbhits 0 time 2470 pv b1c3 b8c6 e2e3 f5f4 g2g3 d7d5 d2d4 g8e7 f2g2 f4e3 c1e3 e7f5

after 2nd move of Hirneise vs. Hirneise (2010):

position fen r1bqkbnr/pppppppp/n7/8/8/7N/PPPPPPPP/RNBQKB1R w KQkq - 2 2
go movetime 10000
info depth 19 seldepth 24 multipv 1 score cp 16 nodes 7228257 nps 723259 tbhits 0 time 9994 pv d2d4 g8f6 e2e3 e7e6 c2c4 d7d5 b1c3 f8e7 f1e2

In these consecutive uses of the engine, I am solely interested in score cp -71 and score cp 16

It seems that the Hash is not used at all and thus I can set it to zero. Is that correct? Is there a way to disable the Hash entirely in the UCI specification? The reason I ask is I am using a mobile device so conserving memory is more relevant.

2

Short answer

No, don't set it to zero, in fact the more the better. Stockfish is using the hash table very heavily, just that you can't see it.

Long answer

Let's briefly cover hashing in a non-technical way

Q: What is hash table?

Hash table is an internal data structure in chess engines to "memorize" previously searched positions. It's like the black-hole; you can't see it but it's part of the galaxy.

Q: Why hash table?

Because we don't want to the engine search the same position again and again. There're lots of repetitions in chess, hash table is a simple but very effective strategy to deal with them. Hash table also helps move reductions and pruncing.

Let's look at the quote:

Hash size is the amount of memory you want to designate for Stockfish to store positions (a temporary hash). You don't want your hash size to exceed your physical memory, but you don't want it to be too small either.

If your computer has 4GB of RAM, you wouldn't set it over 4GB (google virtual memory if you are interested to learn more). But at the same time, making it too small would be a waste of resources. You would have to pay for the electricity to power up the computer anyway, so we want to maximise the size of the hash table as much as possible without affecting the overall performance.

Let's pretend we are using Stockfish to analyze the starting position.

You were confused because you thought hashing is like just storing the initial position:

Hash Table : { default position }

This is not correct, because the table is actually being used in the engine search. The hash table would look something like:

Hash Table : { default position, 1.e4, 1.d4, 1.e4 e5, 1.a4, 1.a4 h5 .....}

Although you can't see it, hashing is very important because it memories positions that you will need in the current search and next search. Let's say we play 1.a4, immediately from the hash-table we have an evaluation of 1.a4 h5 from the previous search.

| improve this answer | |
  • 1
    Yes, in other words, the hash table is not storing positions the user ever sees (mostly), it is storing all the millions of positions it sees in its forward search to calculate the value of the current position. And as you say, there are tons of repeats all throughout that search (transpositions, but also piece "tours" and backwards moves). If a position (and already-calculated value) is found in the hash table, it saves having to recalculate the value, which could be very significant for moves higher in the tree, where whole swaths of the tree can avoid being recalculated. – Jeff Y Aug 29 '16 at 21:00

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.