mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-22 10:06:26 +08:00
Simplify signature of remove_piece()
This is a non-functional simplification. Instead of passing the piece type for remove_piece, we can rely on the board. The only exception is en-passant which must be explicitly set because the destination square for the capture is not the same as the piece to remove. Verified also in the Chess960 castling case by running a couple of perft, see the pull request discussion: https://github.com/official-stockfish/Stockfish/pull/2460 STC LLR: 2.94 (-2.94,2.94) [-3.00,1.00] Total: 18624 W: 4147 L: 4070 D: 10407 Ptnml(0-2): 223, 1933, 4945, 1938, 260 http://tests.stockfishchess.org/tests/view/5dfeaa93e70446e17e451163 No functional change
This commit is contained in:
committed by
Stéphane Nicolet
parent
bcf9282844
commit
7a7bcd6359
@@ -174,8 +174,8 @@ private:
|
||||
|
||||
// Other helpers
|
||||
void put_piece(Piece pc, Square s);
|
||||
void remove_piece(Piece pc, Square s);
|
||||
void move_piece(Piece pc, Square from, Square to);
|
||||
void remove_piece(Square s);
|
||||
void move_piece(Square from, Square to);
|
||||
template<bool Do>
|
||||
void do_castling(Color us, Square from, Square& to, Square& rfrom, Square& rto);
|
||||
|
||||
@@ -412,12 +412,13 @@ inline void Position::put_piece(Piece pc, Square s) {
|
||||
psq += PSQT::psq[pc][s];
|
||||
}
|
||||
|
||||
inline void Position::remove_piece(Piece pc, Square s) {
|
||||
inline void Position::remove_piece(Square s) {
|
||||
|
||||
// WARNING: This is not a reversible operation. If we remove a piece in
|
||||
// do_move() and then replace it in undo_move() we will put it at the end of
|
||||
// the list and not in its original place, it means index[] and pieceList[]
|
||||
// are not invariant to a do_move() + undo_move() sequence.
|
||||
Piece pc = board[s];
|
||||
byTypeBB[ALL_PIECES] ^= s;
|
||||
byTypeBB[type_of(pc)] ^= s;
|
||||
byColorBB[color_of(pc)] ^= s;
|
||||
@@ -430,10 +431,11 @@ inline void Position::remove_piece(Piece pc, Square s) {
|
||||
psq -= PSQT::psq[pc][s];
|
||||
}
|
||||
|
||||
inline void Position::move_piece(Piece pc, Square from, Square to) {
|
||||
inline void Position::move_piece(Square from, Square to) {
|
||||
|
||||
// index[from] is not updated and becomes stale. This works as long as index[]
|
||||
// is accessed just by known occupied squares.
|
||||
Piece pc = board[from];
|
||||
Bitboard fromTo = from | to;
|
||||
byTypeBB[ALL_PIECES] ^= fromTo;
|
||||
byTypeBB[type_of(pc)] ^= fromTo;
|
||||
|
||||
Reference in New Issue
Block a user