Pawn hash

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

Karlo Bala
Posts: 373
Joined: Wed Mar 22, 2006 10:17 am
Location: Novi Sad, Serbia
Full name: Karlo Balla

Pawn hash

Post by Karlo Bala »

I'm searching for a post from HGM, posted I don't know, maybe a few years ago. It is about bug due to uninitialized pawn hash, however, cannot remember what was the exact consequence.
Best Regards,
Karlo Balla Jr.
User avatar
hgm
Posts: 27790
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Pawn hash

Post by hgm »

Are you shure it was me? I cannot recall anything.

Two of my engines use Pawn hash: Spartacus and KingSlayer. But in neither case I can imagine anything that would go dramatically wrong when you don't initialize the table. I mean, what can happen? You will ignore everything in there that does not match the Pawn key. Whatever was there initially will not have a higher probability to accidentally match the key than any other value you could initialize it to.

So occasionally you will get wrong information. Whether that information will be able to crash your engine if it is outside a certain range depends very much on what you store, and how you would use it. Wrong scores would certainly not cause fatal errors. But indicating, say, passers might cause trouble if the stored square number is off board.
Karlo Bala
Posts: 373
Joined: Wed Mar 22, 2006 10:17 am
Location: Novi Sad, Serbia
Full name: Karlo Balla

Re: Pawn hash

Post by Karlo Bala »

hgm wrote:Are you shure it was me? I cannot recall anything.
You were right, my apologies ;)
I found the post, it is from A. Scotti. Nasty bug, good to have it in mind.
http://www.talkchess.com/forum/viewtopi ... 73&t=15540

Personally, I store pawns as a key to avoid collisions.
Best Regards,
Karlo Balla Jr.
User avatar
hgm
Posts: 27790
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Pawn hash

Post by hgm »

Ah, that also explains why I never had any problems with this: I usually start with the incremental hash key at some arbitrary non-zero value, because I am too lazy to actually calculate the true hash key of the initial board. So an empty board would not map to a 0 key for me.
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Pawn hash

Post by Evert »

Karlo Bala wrote: I found the post, it is from A. Scotti. Nasty bug, good to have it in mind.
http://www.talkchess.com/forum/viewtopi ... 73&t=15540

Personally, I store pawns as a key to avoid collisions.
While I understand the point (false signature match when there are no pawns), I fail to understand the example mentioned. If there are no pawns, it doesn't really make much sense to award an open-file bonus at all (but it shouldn't make much of a difference either, since all rooks should get it).

I'll take it as a point to apply a "closed file penalty" rather than an "open file bonus" though.