The fascinating collective behaviors of biological systems have inspired extensive studies on shape assembly of robot swarms. Here, we propose a strategy for shape assembly of robot swarms based on the idea of mean-shift exploration: when a robot is surrounded by neighboring robots and unoccupied locations, it would actively give up its current location by exploring the highest density of nearby unoccupied locations in the desired shape. This idea is realized by adapting the mean-shift algorithm, which is an optimization technique widely used in machine learning for locating the maxima of a density function. The proposed strategy empowers robot swarms to assemble highly complex shapes with strong adaptability, as verified by experiments with swarms of 50 ground robots. The comparison between the proposed strategy and the state-of-the-art demonstrates its high efficiency especially for large-scale swarms. The proposed strategy can also be adapted to generate interesting behaviors including shape regeneration, cooperative cargo transportation, and complex environment exploration.