X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=book.c;h=b57407358cc993113c69e4f35d615e7416accb5e;hb=97e95c084e4aacf02203d723937579e898d8e9ee;hp=82d4a45468923c8a84446c1ed0de14843d5199f3;hpb=91d8e5853ca580769cc130aa6ea004869118d171;p=xboard.git diff --git a/book.c b/book.c index 82d4a45..b574073 100644 --- a/book.c +++ b/book.c @@ -30,6 +30,8 @@ #include #include +#include +#include #include "common.h" #include "backend.h" @@ -63,8 +65,6 @@ entry_t entry_none = { }; char *promote_pieces=" nbrqac="; -extern char castlingRights[][BOARD_SIZE]; -extern char epStatus[]; uint64 Random64[781] = { U64(0x9D39247E33776D41), U64(0x2AF7398005AAA5C7), U64(0x44DB015024623547), U64(0x9C15F73E62A76AE2), @@ -273,8 +273,7 @@ uint64 *RandomTurn =Random64+780; uint64 hash(int moveNr) { - char c; - int p, r, f, i, p_enc, squareNr, pieceGroup; + int r, f, p_enc, squareNr, pieceGroup; uint64 key=0, Zobrist; for(f=BOARD_LEFT; f= 0) { - if(castlingRights[moveNr][0] >= 0) key^=RandomCastle[0]; - if(castlingRights[moveNr][1] >= 0) key^=RandomCastle[1]; + if(boards[moveNr][CASTLING][2] != NoRights) { + if(boards[moveNr][CASTLING][0] != NoRights) key^=RandomCastle[0]; + if(boards[moveNr][CASTLING][1] != NoRights) key^=RandomCastle[1]; } - if(castlingRights[moveNr][5] >= 0) { - if(castlingRights[moveNr][3] >= 0) key^=RandomCastle[2]; - if(castlingRights[moveNr][4] >= 0) key^=RandomCastle[3]; + if(boards[moveNr][CASTLING][5] != NoRights) { + if(boards[moveNr][CASTLING][3] != NoRights) key^=RandomCastle[2]; + if(boards[moveNr][CASTLING][4] != NoRights) key^=RandomCastle[3]; } - f = epStatus[moveNr]; + f = boards[moveNr][EP_STATUS]; if(f >= 0 && f < 8){ if(!WhiteOnMove(moveNr)){ // the test for neighboring Pawns might not be needed, @@ -480,7 +479,10 @@ char *ProbeBook(int moveNr, char *book) if(appData.debugMode) fprintf(debugFP, "book key = %08x%08x\n", (unsigned int)(key>>32), (unsigned int)key); offset=find_key(f, key, &entry); - if(entry.key != key) return NULL; + if(entry.key != key) { + fclose(f); + return NULL; + } entries[0] = entry; count=1; fseek(f, 16*(offset+1), SEEK_SET); @@ -499,7 +501,6 @@ char *ProbeBook(int moveNr, char *book) for(i=0; i> 15; // create random < total_weight total_weight = 0; for(i=0; i