Best way to hash pawn positions?

Discussion of chess software programming and technical issues.

Moderator: Ras

monk64

Best way to hash pawn positions?

Post by monk64 »

I notice this page is tragically empty:

https://chessprogramming.wikispaces.com/Pawn+Hash+Table

So...what is the best way to create a pawn position hash table?

Is it enough to simplify the Zobrist method and only consider pawn squares? i.e.,

- generate 2 colors * 48 squares (2nd to 7th rank) = 96 random keys
- hash the key against the random number for each pawn on each square

And what about cases where you only want to look at one side's pawns? Would 48 random keys be enough?
jwes
Posts: 778
Joined: Sat Jul 01, 2006 7:11 am

Re: Best way to hash pawn positions?

Post by jwes »

The easiest is to use the same Zobrist keys you use for the TT, and only hash in pawn moves and captures of pawns.
Gerd Isenberg
Posts: 2251
Joined: Wed Mar 08, 2006 8:47 pm
Location: Hattingen, Germany

Re: Best way to hash pawn positions?

Post by Gerd Isenberg »

monk64 wrote:I notice this page is tragically empty:

https://chessprogramming.wikispaces.com/Pawn+Hash+Table

So...what is the best way to create a pawn position hash table?

Is it enough to simplify the Zobrist method and only consider pawn squares? i.e.,

- generate 2 colors * 48 squares (2nd to 7th rank) = 96 random keys
- hash the key against the random number for each pawn on each square

And what about cases where you only want to look at one side's pawns? Would 48 random keys be enough?
Yes, it is on my todo list ;-)

Most common and simple seems a dedicated Zobrist key, only considering squares occupied by pawns. Another idea is to use the 96 relevant bits of the white and black pawn-bitboards as key and to fold them down to an index range, f.i.

Code: Select all

pawnHashindex = (whitepawnBB - blackpawnBB) * magic >> (64-numbits)