X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=book.c;h=caa61b178458be189ba5d0e67f85e6b5f7416ae8;hb=0bf664e507241790adc9f419b24be4d1d5963b28;hp=dc814586ecd335bd8a3743945ba2315f6286477d;hpb=008288b467c8f2c94508b957d078915f121cc22c;p=xboard.git diff --git a/book.c b/book.c index dc81458..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); @@ -328,7 +329,8 @@ hash (int moveNr) pieceGroup = p_enc / 12; p_enc = p_enc % 12; Zobrist = RandomPiece[64*p_enc + (squareNr & 63)]; - switch(pieceGroup) { + if(pieceGroup & 4) Zobrist *= 987654321; + switch(pieceGroup & 3) { case 1: // pieces 5-10 (FEACWM) Zobrist = (Zobrist << 16) ^ (Zobrist >> 48); break; @@ -339,7 +341,9 @@ hash (int moveNr) Zobrist = (Zobrist << 48) ^ (Zobrist >> 16); break; } - if(squareNr >= 64) Zobrist = (Zobrist << 8) ^ (Zobrist >> 56); + 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 if(f == BOARD_LEFT-2) holdingsKey += Zobrist * boards[moveNr][r][f+1]; else if(f == BOARD_RGHT+1) holdingsKey += Zobrist * boards[moveNr][r][f-1]; else @@ -500,11 +504,19 @@ move_to_string (char move_s[6], uint16 move) move_s[2] = tf + 'a'; move_s[3] = tr + '1' - (BOARD_HEIGHT > 9); + if(IS_SHOGI(gameInfo.variant) && p) { + if(p == 2) p = 10; // Lion moves, for boards so big that 10 is out of range + else if(p != 7) p = 8; // use '+' for all others that do not explicitly defer + } + // kludge: encode drops as special promotion code if(gameInfo.holdingsSize && p == 9) { move_s[0] = f + '@'; // from square encodes piece type move_s[1] = '@'; // drop symbol p = 0; + } else if(p == 10) { // decode Lion move + + p = 0; } // add promotion piece, if any @@ -714,7 +726,7 @@ char * MovesToText(int count, entry_t *entries) { int i, totalWeight = 0; - char algMove[6]; + char algMove[12]; char *p = (char*) malloc(40*count+1); for(i=0; i