mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-22 01:56:58 +08:00
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:
18
src/uci.cpp
18
src/uci.cpp
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user