The mobile sensor network can sense and collect the data information of the monitored object in real time in the monitoring area. However, the collected information is meaningful only if the location of the node is known. This paper mainly optimizes the Monte Carlo Localization (MCL) in mobile sensor positioning technology. In recent years, the rapid development of heuristic algorithms has provided solutions to many complex problems. This paper combines the compact strategy into the adaptive particle swarm algorithm and proposes a compact adaptive particle swarm algorithm (cAPSO). The compact strategy replaces the specific position of each particle by the distribution probability of the particle swarm, which greatly reduces the memory usage. The performance of cAPSO is tested on 28 test functions of CEC2013, and compared with some existing heuristic algorithms, it proves that cAPSO has a better performance. At the same time, cAPSO is applied to MCL technology to improve the accuracy of node localization, and compared with other heuristic algorithms in the accuracy of MCL, the results show that cAPSO has a better performance.