- bookFile.seekg(n * EntrySize, std::ios_base::beg);
- if (!bookFile.good())
- {
- std::cerr << "Failed to read book entry at index " << n << std::endl;
- bookFile.close();
- exit(EXIT_FAILURE);
- }
- entry.key = read_integer64(bookFile);
- entry.move = read_integer16(bookFile);
- entry.count = read_integer16(bookFile);
- entry.n = read_integer16(bookFile);
- entry.sum = read_integer16(bookFile);
-}
-
-
-////
-//// Local definitions
-////
-
-namespace {
-
- uint64_t book_key(const Position& pos) {
-
- uint64_t result = 0ULL;
-
- for (Color c = WHITE; c <= BLACK; c++)
- {
- Bitboard b = pos.pieces_of_color(c);
-
- while (b != EmptyBoardBB)
- {
- Square s = pop_1st_bit(&b);
- Piece p = pos.piece_on(s);
-
- assert(piece_is_ok(p));
- assert(color_of_piece(p) == c);
-
- result ^= book_piece_key(p, s);
- }
- }
-
- result ^= book_castle_key(pos);
- result ^= book_ep_key(pos);
- result ^= book_color_key(pos);
- return result;
- }
-