May 3, 2007

[Other] Setting hash table size

I have been working a bit with an eval hash table and pawn hash table. The eval hash table seems to be a quite noticeable improvement and is very easy to implement, there are a few tweaks I can come up with but in general it is pretty straight forward.

The pawn hash table on the other hand is a bit more complicated since it is only part of the evaluation and some things needs to be worked out on every call to evaluation (like the attack table). To take full advantage of the pawn hash it also needs to store information about passed pawns so we do not have to find them every time.

Because of this I had some doubts of how much the pawn hash would actually help, but since the pawn structure changes very rarely it should be a nice boost as long as it gets implemented smoothly.

Sizes

Now Mediocre will have three hash tables, main transposition table, eval hash, and pawn hash (and the repetition table, but it is so small it hardly counts). So what sizes should these have?

In Scorpio the default sizes are 16mb for main transposition table, and 8mb each for eval and pawn hash. These ratios seems quite logical (i.e. twice as big main transposition table as eval and pawn hash).

I could implement these sizes in the code directly, but it would be a lot smoother if the user could choose this, and this is currently not possible in Mediocre.

So it is time to be able to choose the hash table size in Mediocre. I have been meaning to do this for quite some time but it seems I always end up trying to implement some playing improvement feature instead.

The UCI protocol comes with a command where the hash size can be set, while Winboard lacks this option. Since Mediocre supports both protocols I am going to start with creating a settings file where the hash size can bet set, and later make it possible to change through the interface using UCI (during run time).

Since we have a settings file we might as well implement a few more settings to choose from. Like if the own opening book should be used or not.

Paths

I ran into a problem when trying to let the settings file decide in what directory the opening book should be located. Since Java is supposed to work on several platforms you have to be careful with using absolute paths. E.g. C:\books\book.zip will not work on a Unix machine.

So to be safe the paths should be e.g. ./books/book.zip

The real problem however was getResourceAsStream (which is used in the Book class) uses the path the file running is in, and not the path the application was started from. So if we use the Mediocre.bat to start Mediocre and have the the binaries in the bin-folder we need to use the current directory to find the Mediocre settings file, but ../book.zip to find the book file if it is located with the Mediocre.bat.

Messy? Yeah. :)

The problem is I can never know if the user is using an executable which will have book.zip in the same folder, or Mediocre.bat which will probably have the book.zip in the parent folder, so both folders will have to be tried which can get messy since getResourceAsStream uses another root directory.

The problem with book.zip is an old problem I have had. So far I have always had it in the bin-folder which is not logical.

I think I will sidestep all this and just assume all files Mediocre needs will be located in the same folder.

More settings

In future releases I might make it possible to change evaluation terms through the settings file as well as things like table bases and such.

(thanks to Tord Romstad for clearing up a few issues with hash tables for me)

2 comments:

Anonymous said...

Hi, how do you get the engine to load in Chessbase GUI? I tried but the Fritz interface could not recognize any of the files.

Jonatan Pettersson said...

Chessbase doesn't like the bat-files java-programs use.

Instead use the executable version (compiled by Jim Ablett).