- byTypeBB[pt] ^= s;
- byColorBB[c] ^= s;
- /* board[s] = NO_PIECE; Not needed, overwritten by the capturing one */
- Square lastSquare = pieceList[c][pt][--pieceCount[c][pt]];
- index[lastSquare] = index[s];
- pieceList[c][pt][index[lastSquare]] = lastSquare;
- pieceList[c][pt][pieceCount[c][pt]] = SQ_NONE;
- pieceCount[c][ALL_PIECES]--;
-}
-
-inline void Position::move_piece(Color c, PieceType pt, 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.
- Bitboard from_to_bb = SquareBB[from] ^ SquareBB[to];
- byTypeBB[ALL_PIECES] ^= from_to_bb;
- byTypeBB[pt] ^= from_to_bb;
- byColorBB[c] ^= from_to_bb;
+ byTypeBB[type_of(pc)] ^= s;
+ byColorBB[color_of(pc)] ^= s;
+ board[s] = NO_PIECE;
+ pieceCount[pc]--;
+ pieceCount[make_piece(color_of(pc), ALL_PIECES)]--;
+ psq -= PSQT::psq[pc][s];
+}
+
+inline void Position::move_piece(Square from, Square to) {
+
+ Piece pc = board[from];
+ Bitboard fromTo = from | to;
+ byTypeBB[ALL_PIECES] ^= fromTo;
+ byTypeBB[type_of(pc)] ^= fromTo;
+ byColorBB[color_of(pc)] ^= fromTo;