With the continuous development of artificial intelligence, swarm control and other technologies, the application of Unmanned Aerial Vehicles (UAVs) in the battlefield is more and more extensive, and the UAV swarm is increasingly playing a prominent role in the future of warfare. How tasks are assigned in the dynamic and complex battlefield environment is very important. This paper proposes a task assignment model and its objective function based on dynamic information convergence. In order to resolve this multidimensional function, the Wolf Pack Algorithm (WPA) is selected as the alternative optimization algorithm. This is because its functional optimization of high-dimensional complex problems is better than other intelligent algorithms, and the fact that it is more suitable for UAV swarm task allocation scenarios. Based on the traditional WPA algorithm, this paper proposes a Multi-discrete Wolf Pack Algorithm (MDWPA) to solve the UAV task assignment problem in a complex environment through the discretization of wandering, calling, sieging behavior, and new individual supplement. Through Orthogonal Experiment Design (OED) and analysis of variance, the results show that MDWPA performs with better accuracy, robustness, and convergence rate and can effectively solve the task assignment problem of UAVs in a complex dynamic environment.