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:
@@ -166,19 +166,19 @@ void MovePicker::score() {
|
||||
for (auto& m : *this)
|
||||
if constexpr (Type == CAPTURES)
|
||||
m.value =
|
||||
(7 * int(PieceValue[pos.piece_on(to_sq(m))])
|
||||
+ (*captureHistory)[pos.moved_piece(m)][to_sq(m)][type_of(pos.piece_on(to_sq(m)))])
|
||||
(7 * int(PieceValue[pos.piece_on(m.to_sq())])
|
||||
+ (*captureHistory)[pos.moved_piece(m)][m.to_sq()][type_of(pos.piece_on(m.to_sq()))])
|
||||
/ 16;
|
||||
|
||||
else if constexpr (Type == QUIETS)
|
||||
{
|
||||
Piece pc = pos.moved_piece(m);
|
||||
PieceType pt = type_of(pos.moved_piece(m));
|
||||
Square from = from_sq(m);
|
||||
Square to = to_sq(m);
|
||||
Square from = m.from_sq();
|
||||
Square to = m.to_sq();
|
||||
|
||||
// histories
|
||||
m.value = 2 * (*mainHistory)[pos.side_to_move()][from_to(m)];
|
||||
m.value = 2 * (*mainHistory)[pos.side_to_move()][m.from_to()];
|
||||
m.value += 2 * (*pawnHistory)[pawn_structure_index(pos)][pc][to];
|
||||
m.value += 2 * (*continuationHistory[0])[pc][to];
|
||||
m.value += (*continuationHistory[1])[pc][to];
|
||||
@@ -211,12 +211,12 @@ void MovePicker::score() {
|
||||
else // Type == EVASIONS
|
||||
{
|
||||
if (pos.capture_stage(m))
|
||||
m.value = PieceValue[pos.piece_on(to_sq(m))] - Value(type_of(pos.moved_piece(m)))
|
||||
m.value = PieceValue[pos.piece_on(m.to_sq())] - Value(type_of(pos.moved_piece(m)))
|
||||
+ (1 << 28);
|
||||
else
|
||||
m.value = (*mainHistory)[pos.side_to_move()][from_to(m)]
|
||||
+ (*continuationHistory[0])[pos.moved_piece(m)][to_sq(m)]
|
||||
+ (*pawnHistory)[pawn_structure_index(pos)][pos.moved_piece(m)][to_sq(m)];
|
||||
m.value = (*mainHistory)[pos.side_to_move()][m.from_to()]
|
||||
+ (*continuationHistory[0])[pos.moved_piece(m)][m.to_sq()]
|
||||
+ (*pawnHistory)[pawn_structure_index(pos)][pos.moved_piece(m)][m.to_sq()];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ Move MovePicker::select(Pred filter) {
|
||||
|
||||
cur++;
|
||||
}
|
||||
return MOVE_NONE;
|
||||
return Move::none();
|
||||
}
|
||||
|
||||
// Most important method of the MovePicker class. It
|
||||
@@ -278,8 +278,7 @@ top:
|
||||
endMoves = std::end(refutations);
|
||||
|
||||
// If the countermove is the same as a killer, skip it
|
||||
if (refutations[0].move == refutations[2].move
|
||||
|| refutations[1].move == refutations[2].move)
|
||||
if (refutations[0] == refutations[2] || refutations[1] == refutations[2])
|
||||
--endMoves;
|
||||
|
||||
++stage;
|
||||
@@ -287,7 +286,7 @@ top:
|
||||
|
||||
case REFUTATION :
|
||||
if (select<Next>([&]() {
|
||||
return *cur != MOVE_NONE && !pos.capture_stage(*cur) && pos.pseudo_legal(*cur);
|
||||
return *cur != Move::none() && !pos.capture_stage(*cur) && pos.pseudo_legal(*cur);
|
||||
}))
|
||||
return *(cur - 1);
|
||||
++stage;
|
||||
@@ -308,8 +307,7 @@ top:
|
||||
|
||||
case QUIET :
|
||||
if (!skipQuiets && select<Next>([&]() {
|
||||
return *cur != refutations[0].move && *cur != refutations[1].move
|
||||
&& *cur != refutations[2].move;
|
||||
return *cur != refutations[0] && *cur != refutations[1] && *cur != refutations[2];
|
||||
}))
|
||||
return *(cur - 1);
|
||||
|
||||
@@ -343,7 +341,7 @@ top:
|
||||
|
||||
// If we did not find any move and we do not try checks, we have finished
|
||||
if (depth != DEPTH_QS_CHECKS)
|
||||
return MOVE_NONE;
|
||||
return Move::none();
|
||||
|
||||
++stage;
|
||||
[[fallthrough]];
|
||||
@@ -360,7 +358,7 @@ top:
|
||||
}
|
||||
|
||||
assert(false);
|
||||
return MOVE_NONE; // Silence warning
|
||||
return Move::none(); // Silence warning
|
||||
}
|
||||
|
||||
} // namespace Stockfish
|
||||
|
||||
Reference in New Issue
Block a user