- pieceList[c][pt][index[lastSquare]] = lastSquare;
- pieceList[c][pt][pieceCount[c][pt]] = SQ_NONE;
- pieceCount[c][ALL_PIECES]--;
+ pieceList[pc][index[lastSquare]] = lastSquare;
+ pieceList[pc][pieceCount[pc]] = SQ_NONE;
+ pieceCount[make_piece(color_of(pc), ALL_PIECES)]--;
+ psq -= PSQT::psq[pc][s];
+}
+
+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;
+ byColorBB[color_of(pc)] ^= fromTo;
+ board[from] = NO_PIECE;
+ board[to] = pc;
+ index[to] = index[from];
+ pieceList[pc][index[to]] = to;
+ psq += PSQT::psq[pc][to] - PSQT::psq[pc][from];
+}
+
+inline void Position::do_move(Move m, StateInfo& newSt) {
+ do_move(m, newSt, gives_check(m));
+}
+
+inline StateInfo* Position::state() const {
+
+ return st;