Author: Dan Newman
Date: 00:56:13 07/14/01
Go up one level in this thread
On July 14, 2001 at 01:59:31, TEERAPONG TOVIRAT wrote:
>Hi,
>
>I've been trying to reduce my hashtable size,so that I can gain
>more entries. At first,I try to pack three structure tag into one
>integer it looks like this...
>
> new integer = (flag<<a)|(depth<<b)|(value)
>
>It fails because value is signed int the rest are unsigned.
>Could anyone solve the problem?
>
>Thanks in advance,
>Teerapong
What I do is this:
integer = (flag<<a) | (depth<<b) | (value+32768);
which assumes that "value" will never be less than -32768.
(This is not necessarily a safe assumption though. I had a bug
involving adjustments to mate-scores that caused my score to go
below -32768 and trash my flags...)
To get the number back you just do this:
value = (integer & 0xffff) - 32768;
I hide all this mess inside a class so that I don't have to
deal directly with shifts and masks in my transposition table
code.
It might be cleaner and clearer to do as Bruce suggests and
simply use a struct with an element for each thing. In
tests I've found packing ints to be a little bit faster than
using individual elements, but packing is very much more
error prone, and I have slowly come to realize that that may
be more important than a little gain in speed...
-Dan.
This page took 0.01 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.