Change the Move enum to a class

This changes the Move enum to a class, this way
all move related functions can be moved into the class
and be more self contained.

closes https://github.com/official-stockfish/Stockfish/pull/4958

No functional change
This commit is contained in:
Disservin
2024-01-01 23:13:18 +01:00
parent 28f8663f39
commit cafbe8e8e8
12 changed files with 241 additions and 222 deletions

View File

@@ -75,7 +75,7 @@ void position(Position& pos, std::istringstream& is, StateListPtr& states) {
pos.set(fen, Options["UCI_Chess960"], &states->back(), Threads.main());
// Parse the move list, if any
while (is >> token && (m = UCI::to_move(pos, token)) != MOVE_NONE)
while (is >> token && (m = UCI::to_move(pos, token)) != Move::none())
{
states->emplace_back();
pos.do_move(m, states->back());
@@ -395,22 +395,22 @@ std::string UCI::square(Square s) {
// Internally, all castling moves are always encoded as 'king captures rook'.
std::string UCI::move(Move m, bool chess960) {
if (m == MOVE_NONE)
if (m == Move::none())
return "(none)";
if (m == MOVE_NULL)
if (m == Move::null())
return "0000";
Square from = from_sq(m);
Square to = to_sq(m);
Square from = m.from_sq();
Square to = m.to_sq();
if (type_of(m) == CASTLING && !chess960)
if (m.type_of() == CASTLING && !chess960)
to = make_square(to > from ? FILE_G : FILE_C, rank_of(from));
std::string move = UCI::square(from) + UCI::square(to);
if (type_of(m) == PROMOTION)
move += " pnbrqk"[promotion_type(m)];
if (m.type_of() == PROMOTION)
move += " pnbrqk"[m.promotion_type()];
return move;
}
@@ -427,7 +427,7 @@ Move UCI::to_move(const Position& pos, std::string& str) {
if (str == UCI::move(m, pos.is_chess960()))
return m;
return MOVE_NONE;
return Move::none();
}
} // namespace Stockfish