The Slime Mold Algorithm (SMA) is a popular optimization algorithm in recent years. However, it suffers from weaknesses in exploration capability, insufficient balance, and a tendency to get trapped in local optima. To address these issues, this paper proposes a novel Slime Mold Algorithm based on Cosine Similarity and Population Range Neighborhood Selection Mechanism (CSSMA).Firstly, a population range neighborhood selection mechanism is designed to enhance the algorithm's exploration capability. This mechanism allows for a better exploration of the solution space during the optimization process. Next, an embedded uniform nonlinear adaptive operator is introduced to improve the balance between exploration and exploitation in SMA. This step ensures that the algorithm can effectively explore promising areas while also exploiting the identified regions.Moreover, a cosine similarity-based escape mechanism is proposed to enhance the optimization precision and promote population diversity in SMA. This mechanism assists the algorithm in breaking away from local optima and exploring the global solution space more effectively.In the validation phase, CSSMA is evaluated using 12 selected test functions out of 23 classic test functions through ablation experiments. Additionally, numerical experiments and Wilcoxon rank-sum tests are performed on all 23 test functions to compare the performance of the proposed improvements with other benchmark algorithms. The results validate the effectiveness of the proposed CSSMA, as it demonstrates a significant improvement in optimization precision and overall performance, making it more competitive than other compared algorithms.