X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fbook.cpp;h=fcaccf6f7560fe92c24cccc22428166f77ca5e03;hp=8944b31bdb3d8d63bd19e9da206b196af7ababed;hb=2225e3bbe785f29dfcdb2b1057e1f141002f44c8;hpb=de58594b0f95115109d0c8aeb56a6c5c85b94b9f diff --git a/src/book.cpp b/src/book.cpp index 8944b31b..fcaccf6f 100644 --- a/src/book.cpp +++ b/src/book.cpp @@ -322,16 +322,16 @@ namespace { result ^= ZobPiece[PieceOfs[pos.piece_on(s)] + s]; } - if (pos.can_castle_kingside(WHITE)) + if (pos.can_castle(WHITE_OO)) result ^= ZobCastle[0]; - if (pos.can_castle_queenside(WHITE)) + if (pos.can_castle(WHITE_OOO)) result ^= ZobCastle[1]; - if (pos.can_castle_kingside(BLACK)) + if (pos.can_castle(BLACK_OO)) result ^= ZobCastle[2]; - if (pos.can_castle_queenside(BLACK)) + if (pos.can_castle(BLACK_OOO)) result ^= ZobCastle[3]; if (pos.ep_square() != SQ_NONE) @@ -455,18 +455,16 @@ Move Book::get_move(const Position& pos, bool findBestMove) { // book move is a promotion we have to convert to our representation, in // all other cases we can directly compare with a Move after having // masked out special Move's flags that are not supported by PolyGlot. - int p = (bookMove >> 12) & 7; + int promotion = (bookMove >> 12) & 7; - if (p) + if (promotion) bookMove = int(make_promotion_move(move_from(Move(bookMove)), - move_to(Move(bookMove)), PieceType(p + 1))); - - // Verify the book move (if any) is legal - MoveStack mlist[MAX_MOVES]; - MoveStack* last = generate(pos, mlist); - for (MoveStack* cur = mlist; cur != last; cur++) - if ((int(cur->move) & ~(3 << 14)) == bookMove) // Mask out special flags - return cur->move; + move_to(Move(bookMove)), + PieceType(promotion + 1))); + // Verify the book move is legal + for (MoveList ml(pos); !ml.end(); ++ml) + if ((ml.move() & ~(3 << 14)) == bookMove) // Mask out special flags + return ml.move(); return MOVE_NONE; } @@ -513,7 +511,7 @@ Book& Book::operator>>(T& n) { n = 0; for (size_t i = 0; i < sizeof(T); i++) - n = (n << 8) + (T)bookFile.get(); + n = T((n << 8) + bookFile.get()); return *this; }