Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: boundschecking

Author: Dieter Buerssner

Date: 06:09:57 11/04/02

Go up one level in this thread


On November 04, 2002 at 08:44:51, Uri Blass wrote:

Sorry for the empty post.

>Sorry but I do not understand what is the advantage of unsigned and
>what is "PRNG based on Maraglia"

The author of the Pseudo Random Number Generator (PRNG) is George Marsaglia (in
my first post there is a typo with his name).

unsigned types are more natural for types where bitlevel operations are needed,
and less prone to errors. But I agree, that for normal Zorbrist hashing, this is
probabably not needed.

One example not totally unrealistic example, where it could go wrong.

   size_t index; /* Assume it is a 32 bit quantity */
   index = hash_key >> some_shift_value;

one might easily assume, that when some_shift_value is 44, that index will have
at most 20 set bits, so one might wrongly use this index for adressing a 1M big
table. But when hash_key is starting with a leading 1 bit and has a signed type,
this will probably yield in an index, that has 13 leading 1 bits, due to sign
extension done typically (but this is not guaranteed).

unsigned numbers don't show such problems, and will allways shift in 0 from the
left with >>. Other arithmetic is also properly defined by the C-Standard for
unsigned. For example overflows/underflows when adding/subtracting 2 values
(instead of the xor to update hash_key with new piece placement, one could use
+, and - to delete a piece from the board).

Regards,
Dieter




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.