From: H.G.Muller Date: Tue, 3 Mar 2015 21:44:32 +0000 (+0100) Subject: Change book Zobrist key for Chu promoted pieces X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=b3045790c3486c4ddcaeb6525874f300085a7deb;hp=143a5473aa9fae9804a781575f4652dcf89f0bbb;p=xboard.git Change book Zobrist key for Chu promoted pieces Promoted pieces for Chu (i.e. above Lion, with the exception of King) now get keys derived from their base type, by XORing in a square-dependent 'promoted' key. This makes it possible to extend the unpromoted series with new pieces without altering the keys for the promoted pieces. So that the current book code works upto 48 unpromoted piece types, rather than 48 piece types total. --- diff --git a/book.c b/book.c index 8b4a43c..caa61b1 100644 --- a/book.c +++ b/book.c @@ -313,8 +313,9 @@ hash (int moveNr) ChessSquare p = boards[moveNr][r][f]; if(f == BOARD_LEFT-1 || f == BOARD_RGHT) continue; // between board and holdings if(p != EmptySquare){ - int j = (int)p; + int j = (int)p, promoted = 0; j -= (j >= (int)BlackPawn) ? (int)BlackPawn :(int)WhitePawn; + if(j >= CHUPROMOTED WhitePawn) promoted++, j -= CHUPROMOTED WhitePawn; if(j > (int)WhiteQueen) j++; // make space for King if(j > (int) WhiteKing) j = (int)WhiteQueen + 1; p_enc = 2*j + ((int)p < (int)BlackPawn); @@ -340,6 +341,7 @@ hash (int moveNr) Zobrist = (Zobrist << 48) ^ (Zobrist >> 16); break; } + if(promoted) Zobrist ^= 123456789*RandomPiece[squareNr & 63]; if(squareNr & 64) Zobrist = (Zobrist << 8) ^ (Zobrist >> 56); if(squareNr & 128) Zobrist = (Zobrist << 4) ^ (Zobrist >> 60); // holdings have separate (additive) key, to encode presence of multiple pieces on same square