A multi-agent system with multiple agents capable of completing complex tasks.In view of the formation of multi-agent in complex environment and the formation reorganization when the formation is impacted,a distributed formation control method based on the discrete layer of formation shape is proposed.Firstly,the formation shape is discretized and iterative,its influence range is expanded,and the formation information is shared with each agent.Secondly,for environments with obstacles,a dynamic negotiation algorithm is designed to adjust the formation's assembly position in real time.Finally,a speed controller is designed using sensor information and formation shape data,employing a distributed control method to achieve dynamic obstacle avoidance and manage complex formations.Experimental results show that the proposed method effectively guides multiple agents in forming complex formation shapes and enables formation obstacle avoidance,offset adjustment,and reorganization in environments with obstacles.Evaluation and analysis of the experimental results,using metrics for formation shaping time and perfor-mance,validate the method's strong environmental adaptability and effectiveness.