Looking for solution to TB lookup problem.

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

SteveJ

Looking for solution to TB lookup problem.

Post by SteveJ »

I'm an unskilled, but diligent, hobbyist programmer. Over the last several years my program has developed a very good opening book search code, however, I'm still having trouble with the endgame DB lookup.

The problem is that every time I want to lookup a position in the TB, my program has to open the file, which takes a very long time. As can be imagined, having to take 1 minute to open the file for each position checked limits the use of the TB to one ply!!

The way my program works is that when my alpha beta search detects 4 pieces or less, it goes to a function that opens the DB, looks up the position, and dutifully returns the value a minute or so later.

For test purposes, I've had the program look up 20 positions (instead of one) in the function and it returns all 20 values correctly in the same one minute.

Does anyone have suggestions as to how this can be avoided? Is there a way to keep the DB file open so that it can be accessed by future function calls?

Thank you.
Steve
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Looking for solution to TB lookup problem.

Post by bob »

SteveJ wrote:I'm an unskilled, but diligent, hobbyist programmer. Over the last several years my program has developed a very good opening book search code, however, I'm still having trouble with the endgame DB lookup.

The problem is that every time I want to lookup a position in the TB, my program has to open the file, which takes a very long time. As can be imagined, having to take 1 minute to open the file for each position checked limits the use of the TB to one ply!!

The way my program works is that when my alpha beta search detects 4 pieces or less, it goes to a function that opens the DB, looks up the position, and dutifully returns the value a minute or so later.

For test purposes, I've had the program look up 20 positions (instead of one) in the function and it returns all 20 values correctly in the same one minute.

Does anyone have suggestions as to how this can be avoided? Is there a way to keep the DB file open so that it can be accessed by future function calls?

Thank you.


Steve
This is an easy one. Open all the files once, when you start the program. You can have an array of file handles to deal with this. If you use Eugene's compressed file approach, he also reads in the "decompression indices" once as he has to malloc() memory for those. Now, when you need to probe, you just probe without opening or reading anything other than the actual data needed.
SteveJ

Re: Looking for solution to TB lookup problem.

Post by SteveJ »

Thank you, Dr. Hyatt. Will try it out.

Steve