Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Books

Author: Peter McKenzie

Date: 18:26:25 04/20/99

Go up one level in this thread


On April 20, 1999 at 20:34:14, James Robertson wrote:

>On April 20, 1999 at 19:44:35, Peter McKenzie wrote:
>
>>On April 20, 1999 at 19:21:07, James Robertson wrote:
>>
>>>On April 20, 1999 at 11:00:08, James Robertson wrote:
>>>
>>>>I have become dissatisfied with the way my program searches for moves in it's
>>>>book; it simply takes too long. How do other programs do this? If I look at the
>>>>Crafty bookmaking code, I see stuff about "clusters". What does this mean? How
>>>>do EXchess, or Comet or other programs search their books?
>>>>
>>>>Thanks for any help!
>>>>James
>>>
>>>Thanks guys for your responses; let me think about them for a bit. I forgot to
>>>mention: my book is a list of hash codes that are sorted numerically. My engine
>>>jumps around through the numbers until it zeroes in on the hash code that
>>>matches. If there is a match, then that move is in the book. This is wonderful
>>>for small books but gets bad fast with larger ones. For instance, my program
>>>often can only make three book moves a second, and it's book is just 413k (26418
>>>entries).
>>
>>A binary search in memory should let you do this much much faster then 3 every
>>second - perhaps its not the book that is slowing you down?  Or are you doing
>>the binary search on a file?
>
>I am doing the search on a file.
>
>>Even then, with suitable caching, you should get
>>much better speed than reported.
>
>I don't know how to do anything to the caching, so whatever the iostream does by
>default, that is what is happening.

I don't know what exactly is available in the standard libraries, but you could
easily write a class for accessing a file, that incorporated a simple cache.
Here is a simple design:  treat the file as a list of 1K blocks.  Have a list of
 1K blocks in memory as your cache.  When you read a byte from the physical
file, load its entire block into the cache.  Before you read a byte from
physical memory, check whether its block is in the cache or not.

There are a few gotchas, specially if you are writing to the file, but in your
case you're probably only reading from it so no worries.

>
>>How are you timing this - using ICC?  If so, maybe there are other bottlenecks
>>involved...
>
>No... this is straight from the console....



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.