X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fposition.cpp;h=c673225737b2906d428743b8a6f034d60d75d1c9;hp=2b50ff2ae258df7a49eb0d892b79511d41e31908;hb=97dd7568edf74f8797e152258ebe30ecdc8bac0d;hpb=af220cfd52d95e6b05539036ebf9319131dd469d diff --git a/src/position.cpp b/src/position.cpp index 2b50ff2a..c6732257 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -939,6 +939,12 @@ void Position::do_capture_move(Bitboard& key, PieceType capture, Color them, Squ pieceCount[them][capture]--; // Update piece list, move the last piece at index[capsq] position + // + // WARNING: this is a not perfectly revresible operation. When we + // will reinsert the captured piece 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 guaranteed to be invariant to a + // do_move() + undo_move() sequence. Square lastPieceSquare = pieceList[them][capture][pieceCount[them][capture]]; index[lastPieceSquare] = index[capsq]; pieceList[them][capture][index[lastPieceSquare]] = lastPieceSquare;