In my program Sillycon I use 781, 64 bit Zobrist keys.
12x64 Piece squares
8 En-passant
4 Castling rights
1 Wtm
Then I played with the idea to reduce the number of keys by rotating them. So I did that by making them as:
Code: Select all
// Zobrist Hash keys
for (pcs=BKing; pcs <= WKing; pcs++) {
if (pcs == Neutral) pcs++;
HKey[pcs][H8] = Random64();
for (sqr=H7; sqr<=A1; sqr++) HKey[pcs][sqr] = rol64(HKey[pcs][H8],sqr);
}
HKeyEp[0] = Random64();
for (i=1; i<8; i++) HKeyEp[i] = rol64(HKeyEp[0],i); // H-A
for (i=0; i<4; i++) HKeyCastle[i] = Random64();
HKeywtm = Random64();
Code: Select all
inline U64 rol64(U64 A, U8 n)
{
asm volatile("push %%r11;"
"mov %0,%%r11;"
"mov %1,%%cl;"
"shl %%cl,%0;"
"mov $64, %%cl;"
"sub %1,%%cl;"
"shr %%cl,%%r11;"
"or %%r11,%0;"
"pop %%r11;"
:"=r"(A)
:"r"(n),"0"(A)
:"%cl");
return A;
}
depth 8: "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w QKqk -\n"
depth 6: "r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w QKqk- -\n"
depth 5: "4k3/qqqqqqqq/q7/8/8/7Q/QQQQQQQQ/3K4 w - - 0 1\n"
I was a bit surprised that there were no errors! And it should also be possible to use one common (rotated) key for wtm, en-passant and castling properties also. This implies that one only need 13 Zobrist keys=104 bytes, when having the possibility to rotate them in the fly. One drawback is of course that there are no 64 bit rol or ror functions in, at least, my processor (AMD64), but well, they inserted the popcnt in the newer ones.
Regards,
Lasse