Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Simple hash tables programming question

Author: Bruce Moreland

Date: 19:29:33 09/15/00

Go up one level in this thread


On September 15, 2000 at 08:30:10, Jan Pernicka wrote:

> Hi,
>as I'm just fighting with hash tables in my program, my question is about it.
>
>Descriprion: My hash table(s) (HT) are in fact two: one for positions, where
>             white is on move and one where black is on move. This works OK
>             but...
>Problem: It's clear that one table will be much more occupied than second one
>         (because when you sketch the tree of the game to some depth (IE these
>          are positons possibly saved to HT) and label it's nodes as "white to
>          move" or "black to move", then one kind of them will be in greater
>          majority. So my model of HT is inefficient.
>Solution: 1) To have only one HT and with each saved position have a flag
>             indicating side to move.
>          2) To have (also) one HT and evry hashed positon (IE: that 32-bit
>             number in HT...) XOR with some (32-bit) constant depending on side
>             to move.

Pick a number (zero is a bad choice, but others are fine) and XOR it with the
hash key if it is white to move.  You can use a constant.

Side to move is just another aspect of the position.  You wouldn't have a whole
different table if there's a white rook on a1, why have one if it's black to
move?

bruce



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.