(self, square, piece)
Sets a piece at the given square. An existing piece is replaced.
Sets a piece at the given square. An existing piece is replaced.
Sets a piece at the given square . An existing piece is replaced .
def set_piece_at(self, square, piece):
        """Sets a piece at the given square. An existing piece is replaced."""
        self.remove_piece_at(square)

        mask = BB_SQUARES[square]

        if piece.piece_type == PAWN:
            self.pawns |= mask
        elif piece.piece_type == KNIGHT:
            self.knights |= mask
        elif piece.piece_type == BISHOP:
            self.bishops |= mask
        elif piece.piece_type == ROOK:
            self.rooks |= mask
        elif piece.piece_type == QUEEN:
            self.queens |= mask
        elif piece.piece_type == KING:
            self.kings |= mask
            self.king_squares[piece.color] = square

        self.occupied ^= mask
        self.occupied_co[piece.color] ^= mask
        self.occupied_l90 ^= BB_SQUARES[SQUARES_L90[square]]
        self.occupied_r45 ^= BB_SQUARES[SQUARES_R45[square]]
        self.occupied_l45 ^= BB_SQUARES[SQUARES_L45[square]]
def set_piece_at ( self , square , piece ) : self . remove_piece_at ( square ) mask = BB_SQUARES [ square ] if piece . piece_type == PAWN : self . pawns |= mask elif piece . piece_type == KNIGHT : self . knights |= mask elif piece . piece_type == BISHOP : self . bishops |= mask elif piece . piece_type == ROOK : self . rooks |= mask elif piece . piece_type == QUEEN : self . queens |= mask elif piece . piece_type == KING : self . kings |= mask self . king_squares [ piece . color ] = square self . occupied ^= mask self . occupied_co [ piece . color ] ^= mask self . occupied_l90 ^= BB_SQUARES [ SQUARES_L90 [ square ] ] self . occupied_r45 ^= BB_SQUARES [ SQUARES_R45 [ square ] ] self . occupied_l45 ^= BB_SQUARES [ SQUARES_L45 [ square ] ]