diff --git a/src/book/book.cpp b/src/book/book.cpp index 570af9b..82a6716 100644 --- a/src/book/book.cpp +++ b/src/book/book.cpp @@ -82,14 +82,14 @@ namespace Polyfish::Book Move probe(const Position& pos) { int moveNumber = 1 + pos.game_ply() / 2; - Move bookMove = MOVE_NONE; + Move bookMove = Move::none(); for (size_t i = 0; i < NumBooks; ++i) { if (books[i] != nullptr && (int)Options[Utility::format_string("Book %d Depth", i + 1)] >= moveNumber) { bookMove = books[i]->probe(pos, (size_t)(int)Options[Utility::format_string("Book %d Width", i + 1)], (bool)Options[Utility::format_string("(CTG) Book %d Only Green", i + 1)]); - if (bookMove != MOVE_NONE) + if (bookMove != Move::none()) break; } } diff --git a/src/book/ctg/ctg.cpp b/src/book/ctg/ctg.cpp index cef2a12..9ede64d 100644 --- a/src/book/ctg/ctg.cpp +++ b/src/book/ctg/ctg.cpp @@ -286,8 +286,8 @@ namespace CtgMove() : CtgMoveStats() { - pseudoMove = MOVE_NONE; - sfMove = MOVE_NONE; + pseudoMove = Move::none(); + sfMove = Move::none(); annotation = CtgMoveAnnotation::Unknown; recommendation = CtgMoveRecommendation::Unknown; @@ -313,12 +313,12 @@ namespace else if (((rank_of(from) == RANK_7 && rank_of(to) == RANK_8) || (rank_of(from) == RANK_2 && rank_of(to) == RANK_1)) && type_of(pos.piece_on(from)) == PAWN) promotionPiece = QUEEN; - pseudoMove = promotionPiece == NO_PIECE_TYPE ? make_move(from, to) : make<PROMOTION>(from, to, promotionPiece); + pseudoMove = promotionPiece == NO_PIECE_TYPE ? Move(from, to) : Move::make<PROMOTION>(from, to, promotionPiece); } Move pseudo_move() const { - assert(pseudoMove != MOVE_NONE); + assert(pseudoMove != Move::none()); return pseudoMove; } @@ -329,7 +329,7 @@ namespace Move sf_move() const { - assert(sfMove != MOVE_NONE); + assert(sfMove != Move::none()); return sfMove; } @@ -944,7 +944,7 @@ namespace Polyfish::Book::CTG //Check if (index == MoveEncSize) - return MOVE_NONE; + return Move::none(); //Find/Read the move const MoveEnc& moveEnc = moveTable[index]; @@ -961,24 +961,24 @@ namespace Polyfish::Book::CTG Square from = make_square(File(x), Rank(y)); Square to = make_square(File((x + 8 + moveEnc.right) % 8), Rank((y + 8 + moveEnc.forward) % 8)); - return make_move(from, to); + return Move(from, to); } } } //Should never get here assert(false); - return MOVE_NONE; + return Move::none(); } bool CtgBook::get_move(const Position& pos, const CtgPositionData& positionData, int moveNum, CtgMove& ctgMove) const { Move m = get_pseudo_move(positionData, moveNum); - if (m == MOVE_NONE) + if (m == Move::none()) return false; - Square from = from_sq(m); - Square to = to_sq(m); + Square from = m.from_sq(); + Square to = m.to_sq(); if (positionData.invert) { @@ -1022,10 +1022,10 @@ namespace Polyfish::Book::CTG { for (const auto& m : legalMoves) { - if (ctgMove.pseudo_move() == (m.move ^ type_of(m.move))) + if (ctgMove.pseudo_move().raw() == (m.raw() ^ m.type_of())) { //Assign the move - ctgMove.set_sf_move(m.move); + ctgMove.set_sf_move(m); //Play the move p.do_move(ctgMove.sf_move(), si[1]); @@ -1044,7 +1044,7 @@ namespace Polyfish::Book::CTG } } - assert(ctgMove.sf_move() != MOVE_NONE); + assert(ctgMove.sf_move() != Move::none()); } } @@ -1140,17 +1140,17 @@ namespace Polyfish::Book::CTG Move CtgBook::probe(const Position& pos, size_t width, bool onlyGreen) const { if (!is_open()) - return MOVE_NONE; + return Move::none(); CtgPositionData positionData; if (!decode(pos, positionData)) - return MOVE_NONE; + return Move::none(); CtgMoveList ctgMoveList; get_moves(pos, positionData, ctgMoveList); if (ctgMoveList.size() == 0) - return MOVE_NONE; + return Move::none(); //Remove red moves and any moves with negative weight ctgMoveList.erase( @@ -1165,7 +1165,7 @@ namespace Polyfish::Book::CTG //Check move list again after removing unwanted moves if (ctgMoveList.size() == 0) - return MOVE_NONE; + return Move::none(); //Sort moves accorging to their weights stable_sort(ctgMoveList.begin(), ctgMoveList.end(), [](const CtgMove& mv1, const CtgMove& mv2) { return mv1.weight() > mv2.weight(); }); diff --git a/src/book/polyglot/polyglot.cpp b/src/book/polyglot/polyglot.cpp index 67d7319..2651dad 100644 --- a/src/book/polyglot/polyglot.cpp +++ b/src/book/polyglot/polyglot.cpp @@ -339,9 +339,9 @@ namespace // all other cases, we can directly compare with a Move after having masked // out the special Move flags (bit 14-15) that are not supported by Polyglot. Move move = Move(e.move); - int pt = (move >> 12) & 7; + int pt = (move.raw() >> 12) & 7; if (pt) - move = make<PROMOTION>(from_sq(move), to_sq(move), PieceType(pt + 1)); + move = Move::make<PROMOTION>(move.from_sq(), move.to_sq(), PieceType(pt + 1)); return move; } @@ -362,7 +362,7 @@ namespace Move move; PolyglotEntry entry; - PolyglotBookMove() { move = MOVE_NONE; memset(&entry, 0, sizeof(PolyglotEntry)); } + PolyglotBookMove() { move = Move::none(); memset(&entry, 0, sizeof(PolyglotEntry)); } PolyglotBookMove(const PolyglotEntry& e, Move m) { memcpy(&entry, &e, sizeof(PolyglotEntry)); move = m; } }; @@ -450,9 +450,9 @@ namespace Polyfish::Book::Polyglot Move move = make_move(e); for (const auto& m : MoveList<LEGAL>(pos)) { - if (move == (m.move ^ type_of(m.move))) + if (move.raw() == (m.raw() ^ m.type_of())) { - bookMoves.push_back(PolyglotBookMove(e, m.move)); + bookMoves.push_back(PolyglotBookMove(e, m)); } } } @@ -528,13 +528,13 @@ namespace Polyfish::Book::Polyglot Move PolyglotBook::probe(const Position& pos, size_t width, bool /*onlyGreen*/) const { if (!has_data()) - return MOVE_NONE; + return Move::none(); vector<PolyglotBookMove> bookMoves; get_moves(pos, bookMoves); if (!bookMoves.size()) - return MOVE_NONE; + return Move::none(); #if 1 //Remove any move with REALLY low weight compared to the total weight of all moves