Simulation and Analysis of Grid Formation Method for UAV Clusters Based on the 3 × 3 Magic Square and the Chain Rules of Visual Reference

: Large-scale unmanned aerial vehicle (UAV) formations are vulnerable to disintegration under electromagnetic interference and ﬁre attacks. To address this issue, this work proposed a distributed formation method of UAVs based on the 3 × 3 magic square and the chain rules of visual reference. Enlightened by the biomimetic idea of the plane formation of starling ﬂocks, this method adopts the technical means of airborne vision and a cooperative target. The topological structure of the formation’s visual reference network showed high static stability under the measurement of the network connectivity index. In addition, the dynamic self-healing ability of this network was analyzed. Finally, a simulation of a battleﬁeld using matlab showed that, when the loss of UAVs reaches 85% for formations with different scales, the UAVs breaking formation account for 5.1–6% of the total in the corresponding scale, and those keeping formation account for 54.4–65.7% of the total undestroyed ﬂeets. The formation method designed in this paper can maintain the maximum number of UAVs in formation on the battleﬁeld. Conceptualization, R.Q., G.X. and Y.C.; Methodology, R.Q.; Resources, G.X. and Y.C.; Software, R.Q., Z.Y. and J.H.; formal analysis, R.Q.; Writing—original draft, R.Q.; Writing— review and editing, G.X. and R.Q. All authors have read and agreed to the published version of the manuscript.


Introduction
In August 2018, the U.S. Department of Defense released the Unmanned Systems Integrated Roadmap 2017-2042, which reemphasized that the development of autonomous technology is of great importance for improving the efficiency and performance of unmanned systems as well as soldiers [1]. The development of UAVs is an essential part of studying unmanned military systems [2], of which UAV autonomous clusters have become an important direction for the future [3]. Moreover, UAV clusters have begun to play a key role in targeted attacking in the future battlefield with advantages including "defeating the most enemy with the least resources", a flexible and straightforward delivery mode, and ease of avoiding enemy's Air Defense Radar System (ADRS). With this attacking strategy, the successful attack rate can be improved because attacking UAVs require expensive and high precision strike weapons; furthermore, it is difficult for the enemy to find, defend against, and destroy UAVs quickly. Therefore, studying the stable formation method of large-scale UAV clusters has practical implications for military operation.
The UAV cluster formations can be disrupted by strong electromagnetic communication or enemy fire attacks. To address these issues with ideal and mature formation methods, this paper studied the bionic mechanism of the maturely evolved flocks and compared the characteristics of the classical models proposed by scholars worldwide. For example, Vicsek established an essential but straightforward cluster model-the Vicsek model (VM) [46,47]-based on the assumption that the individual field of view (FOV) is 360°, which is not realistic given that this range for most creatures is limited.
Considering the limited FOV, Tian et al. [48] established the RFVN model by upgrading the VM. The Couzin model also considered the FOV issue in studying cluster motion modeling [49]. However, the RFVN model assumes that the direction of FOV is consistent with the individual's moving direction, which is inconsistent with the actual biological perception mode. Therefore, based on the RFVN model, Calvao et al. [49] introduced the limited FOV and the strategy of random line-of-sight (LOS) to establish the Random LOSVM (RLosVM). Furthermore, based on the above models [3] In the FNN model, when one individual refers to the motion state of another in the perception range, its sight may be blocked by others in the formation, making it unable to obtain information about its neighbors effectively. After improving the FNN model, the MFNN model was built, with which individuals can dynamically sense the motion of the nearest "neighbor" in all directions. In addition, Duan Haibin and Qiu Xinhua et al. believed that the VM only considers the information of the previous moment when updating, but the individuals in the actual cluster motion have "memories". This means that the individual decision-making considers not only neighbors' information at the current time, but also previous ones. Therefore, they introduced the fractional calculus idea to the VM and established the fractional order VM (FOVM). The simulation contrast experiments on the above models found that a higher number of neighbors is not necessarily better for the interactions between individuals within a biological cluster. If there are redundancies in the perception information among individuals, the cluster motion cannot achieve faster synchronization, and the synchronised movement of the system will also be interfered with. Therefore, the reasonable distribution of neighboring individuals in space is helpful to reduce redundancies' interactions and improve the information utilization rate [3]. Furthermore, historical information also enhances the efficiency of instant decision making for individuals. However, the above ideas about biomimetic cluster formation models have not been applied to large-scale UAV formations.
In order to integrate the advantages of the VM and its improved models into a largescale UAV formation method, this paper summarized the advantages in each model and proposed the 3 × 3 magic square formation method that is capable of anti-jamming and anti-deception visually. This biomimetic formation method is enlightened by the plane formation of starling flocks and is based on the chain rules for visual reference. It adopts the technical means of airborne vision and cooperative targets and possesses strong antielectromagnetic interference and anti-deception capabilities. In addition, this formation has strong network resilience and regeneration capabilities concerning its network topological structure. With this method, the maximum number of UAVs can be kept in form on the battlefield. The main contributions of this paper are as follows: (1) A distributed formation method for UAVs based on the 3 × 3 magic square and the chain rules of visual reference are proposed in this work; (2) The biomimetic method is enlightened by the formation of starling flocks, and draws on the strengths of the Vicsek model and its refinements [3,[46][47][48][49], overcoming the disadvantages of poor resilience and regeneration capabilities of the existing formation methods ; (3) Matlab simulations and the network connectivity test revealed the strong network resilience and topological regeneration capabilities of this proposed method; (4) This proposed method will significantly improve the ability of formations to resist electromagnetic interference and destruction in the battlefield environment.
The following sections are arranged as follows: Section 2 describes the relevant formation work, such as the formation mechanism of the starling flocks, how a single UAV simulates the distribution of starling's visual sensors, and the cooperative targets' division in the fuselage. Section 3 details the proposed 3 × 3 magic square formation method and describes the matlab simulation of the 11 × 11-scale UAV grid formations. Section 4 analyzes the topological structure stability of the visual reference network based on nested loop nine-grids. Section 5 conducts the matlab simulation experiments and results analyses on different scale UAV formations on the battlefield. Section 6 is the conclusion.

Relevant Formation Work
Before describing the specific formation methods, we need to explain various issues, including the formation mechanism of starling flocks, the distributions of visual sensors, and cooperative targets in the UAVs, etc. These explanations will specify the pre-conditions of the proposed formation methods.

Characteristics of the Formation Mechanism of Starling Flocks
As the most widely distributed birds in the world, starlings are gregarious birds with strong imitation abilities. Thousands of starlings often fly together with a small distance between individuals, and their formations are complex and change frequently with frequent splitting and merging, enabling them to evade predators. Biologists and physicists found that, when a starling flock flies [50][51][52], there is a mutual reference between neighboring individuals, and each starling only interacts with the surrounding 6-7 individuals, as shown in Figure 1. In addition, scholars verified that the choice of reference neighbors is based on the topological model rather than the Euclidean geometric model, as shown in Figures 2 and 3. The position of each bird, i, and its velocity were represented by p i and V i , repetitively, and the dynamics model is where N i is the the total number of individuals that bird i can interact with.
In the Euclidean geometric model, bird i interacts with all neighboring individuals within a fixed distancer, while in the topological model, bird i interacts with its n c neighboring individual, i.e., N i = n c . The specific mathematical model is as follows: Let A = [a ij ] be the adjacency matrix among individuals; then, the Euclidean model is: where r ij (t) is the distance from individual i to j, andr is the distance range established for communication.
Additionally, the topological mode is: where a ij (t 0 ) is the flag bit of the communication at the initialization time a ij . (t 0 ) = 0 indicates no communication connection, and a ij (t 0 ) = 0 means such a connection exists. Second, when the predator is moving in the opposite direction to the flock and there is a vertical offset d, the predator exerts a repulsive force on each bird, which attenuates as the bird moves further away from the predator. As shown by a large number of simulated numerical experiments, under different initial conditions, the clusters of two models present different grouping probabilities after being attacked by predators. Specifically, under the Euclidean model, the flock is usually dispersed into five groups, indicating low restoration capacity of the model. In contrast, it is highly possible for flocks to maintain a complete group under the topological model, and the original group is not easily dispersed, showing strong cohesion. Therefore, it is concluded that when flocks of starlings fly in nature, the choice of reference neighbors is not based on the Euclidean geometric model, but on the topological model [50].   When starlings fly in flocks, the plane direction of the entire formation is integrated. Specifically, the direction and speed of individual movements are initially haphazard, but through continued local interactions between individuals, they eventually fly in the same direction and speed as the movement of the entire flock. The Φ-order parameter is generally used to characterize the synchronization index for the motion direction of all individuals in the starling cluster system. The formula is as follows: where V i represents the speed of the ith starling, and N denotes the total number of the entire flock. The value of Φ will be zero if each starling flies in a different direction and speed; conversely, it will be close to one if most starlings fly in the same direction. Scholars analyzed 24 starling flocks and found that their flight direction has global orderliness [51]. When the perception is uncertain, interacting with the neighboring 6-7 starlings is an optimal choice to balance the cohesion of the flock and individual cost. The plane status of starling flocks can change correlatively: the plane state change of a single starling will affect all other individuals in the entire flock, regardless of the flock size.

The Distribution of Visual Sensors and Cooperative Targets in UAVs Based on the Bionics of Starlings
As the whole plane formation system is based on the formation principle of starling flocks, each UAV in the fleet shall have a similar visual function as a single starling. The compared architecture between starling flocks and UAV fleets is shown in Figure 4: To enable the UAV to observe the flying posture of its surrounding UAVs as starlings do, each UAV was equipped with visual sensors and high-precision ranging sensors on the left side, right side, directly behind and in front (these items of equipment are not necessarily on the directly above and below orientations because the plane formation was conducted on a single plane). For a more visual indication of the orientation, we give a top view of the FOV distribution of a 3 × 3 size UAV formation in Figure 5. As can be seen, there are eight basic directional positions (see details in Figure 6a) determined by the inertial navigation equipment. The flying postures on these positions can be observed by the two sensors equipped. For example, the UAVs numbered 1, 6, 7, 2, 9, 4, 3, and 8 locate the 8th, 1st, 2nd, 3rd, 4th, 5th, 6th, and 7th directions of the No.5 UAV, respectively. These directions were fixed after the UAV joined the formation. No matter how the UAV turned during flying, the eight directions would always remain the initial state (as shown in Figure 6b), so that each UAV can obtain a fixed reference versus the surrounding UAVs. At the same time, the vision system of the UAV can collect the signal conditions of cooperative signal lamps located on the UAV surface in different directions (as shown in Figure 7), thus determining the flying posture of a referenced UAV in each direction. Each UAV can also collect the real-time flying distance between the referenced UAVs and itself together with the high-precision ranging sensors.

Formation Methods and Simulation
Based on the work above, this chapter elaborates the distributed formation method based on the 3 × 3 magic square and the chain rules of visual reference. Using the method, the advantages of the VM and its improved models are integrated into the large-scale UAV cluster formation, so that the VM's redundant neighborhood information can be avoided in its formation. Notably, this method is characterized by a more stable neighborhood information collection than the RLosVM model and the memory function of the FOVM model. In addition, the dynamic visual reference in the FNN model has been improved to enhance the formation's anti-jamming and anti-deception capacity.
First, the formation was divided into two areas, kept at a certain distance to be antijamming. One was the unformatted UAV area, and the other was the formatted area. The involved UAVs could fly freely in the first area and at a random position outside the formatted area. When entering the formatted area, UAVs have their designated routes until arriving at the terminal. However, the routes of all UAVs were constrained by the grid formation, in which each UAV in flight maintained a certain distance, the same altitude and the same speed between them, using airborne distance sensors and their vision system. Based on the 3 × 3 magic square and the chain rules of visual reference, the vision system determines which drones in which directional positions can be referenced to guide the formation.

Distributed Formation Method Based on the 3 × 3 Magic Square and the Chain Rules of Visual Reference
For the formatted areas, a suppositional 3 × 3 magic square grid was set. The size of the square varied according to the scale of formation. Each square was marked with a number to show its position. For instance, Figure 8 is a typical 3 × 3 magic square diagram. When the first UAV entered the formatted area, the very place it arrived was the square numbered 5, as shown in Figure 9. Afterward, the second UAV flew from the unformatted area to the square numbered 1. As mentioned above, the visual sensor of each UAV could sense 8 basic directions in the same plane ( Figure 6). Thus, the eight directions of UAVs in grids 5 and 1 are shown in Figure 10. According to Figures 9 and 10, the UAV in square 1 was in direction 8 of the UAV in square 5, whose airborne visual sensor identified the cooperation signal of the UAV in square 1. Thus, the poses of the UAV in square 1 could be obtained. The UAV in square 1 could offer reference to that in square 5 in direction 8. Similarly, the UAV in square 5 was in direction 4 of the UAV in square 1, whose airborne visual sensor identified the cooperation signal of the UAV in square 5. Therefore, the poses of the UAV in square 5 could be obtained. The UAV in square 5 was set as the reference for the UAV in square 1 in its direction 4. Similarly, through this visual cross-reference, UAVs could be formatted in other parts of the 3 × 3 magic square.
After the formation, a visual reference topological structure diagram of the 3 × 3 magic square was formed, as shown in Figure 11, where node numbers of the square referred to individual UAVs, and the lines between nodes showed the visual reference among UAVs. According to the 3 × 3 magic square agreement and chain rules of visual reference, UAVs to be referred must meet two prerequisites. First, the numbers of UAVs and their reference must be in the same line in the topological structure diagram. Second, in the same line, there must be three nodes in that direction, with each of their numbers adding up to be 15. With these two prerequisites, UAVs at the nodes could be viewed as references. For instance, in Figure 11, UAVs at square 8 would refer to UAVs in square 1 and square 6 in direction 2, UAVs in square 5 and square 2 in direction 3, and UAVs in square 3 and square 4 in direction 4. In these three reference directions (2, 3, and 4), the sum of numbers in the three nodes was 15, satisfying the 3 × 3 magic square agreement and chain rules of visual reference. Thus, UAVs at square 8 could refer to squares 1, 6, 5, 2, 3, and 4. UAVs at square 3 could refer to squares 8, 4, 5, and 7. Similarly, we could get the reference for UAVs at other squares based on this principle. For example, 6 UAVs could be the reference for UAVs at squares 2, 4, 6, and 8, 8 for UAVs at square 5, and 4 for UAVs at square 1, 3, 7, and 9.

Visual Reference Topological Structure Diagram of the Nesting 3 × 3 Magic Squares
To expand the scale of the UAV formation, we expand the magic square by nesting under the exact mechanism of the first 3 × 3 magic square (circling the black dotted bordered rectangle in Figure 12). 3 × 3 magic squares were nested, forming a 7 × 7 magic square formation. For the convenience of studying the formation of UAV clusters, the formation structure after each expansion should be in line with magic squares. For different scale square arrays, the grid numerical codes can be described by the following Equations (6) and (7): where M refers to the number of clusters and n 5 refers to the number of 3 × 3 magic squares. Based on the above formation mechanism and the above equations, we could achieve 11 × 11, 15 × 15, . . . expanded UAV formations. The expanded versions were more complex than the topologies of 3 × 3 magic squares, whose nesting structures made UAV formation more closely related, enhancing the formation stability. For instance, in the 7 × 7 visual reference topological structure diagram of UAV formation, UAVs at square 4 in the red dotted bordered rectangle (Figure 13) satisfied the 3 × 3 magic square agreement and the chain rules of visual reference, as shown in Figure 14. According to the 3 × 3 magic square agreement and chain rules of visual reference, the UAV at square 4 in the red-dotted bordered rectangle could refer to UAVs at squares 5,9,5,3,5,9,5, and 3 (as marked by the blue dashed box in Figure 13) in direction 1-8 as well as squares 6, 2, 6, 8, 6, 2, 6, and 8 (as marked by the green dashed box in Figure 13) in direction 1-8 of the extended nodes. In total, there are 16 UAVs in line with the prerequisites of UAVs for reference, as shown in Figure 14. If they were destroyed, the UAV at square 4 in the red dotted bordered rectangle would be out of the formation.  Similarly, for the UAV at square 1 (as marked by the red dashed box in Figure 15), 4 UVAs meeting the 3 × 3 magic square agreement and the chain rules of visual reference, as shown in Figure 16, respectively, were at neighboring squares 8, 6, and 5 (as marked by the blue dashed box in Figure 15) in direction 2, 6, and 8, as well as square 9 (as marked by the green dashed box in Figure 15) in direction 8 of the extended node. Without these 4 UAVs for reference, the UAV at square 1 will be out of formation. It could be seen that nodes with fewer reference UAVs were located at the margin of the formation. Such is the case of Figure 15, where the UAV at square 1 in the dotted bordered rectangle was in an individual 3 × 3 magic square without nested relation with others.
where i = 1, · · · , N. x i , y i , and h i correspond to the down-range, cross-range, and altitude displacement. V i refers to the airspeed of U AV i , γ i is the plane path angle, and χ i represents the heading angle. T i is the engine thrust, D i refers to drag, m i is the quality of U AV i , and g represents the gravity acceleration. Furthermore, L i refers to lift, and Φ i is the bank angle. Equation (9) can be achieved with the transformation of the mathematical model.
u xi , u yi , and u hi are the subjunctive control input, and the transformation relationship between the executive order and subjunctive control input can be expressed as Equation (10), where tan(χ i ) =ẏ i /ẋ i , and sin(γ i ) =ḣ i /V i . Therefore, the subjunctive control input is designed as Equation (9), and the real input of the UVA could be calculated through Equation (10), which can be expressed as the state place: where z i = [p i T , v i ] T , p i refers to the position vector, v i is the speed vector, and u i = [u T xi , u T yi , u T hi ] T shows the subjunctive control input.
I 3 ∈ R 3×3 refers to the identity matrix, and ⊗ is the Kronecker product. In Equation (10), the air resistance D i can be expressed as Equation (13).
where ρ refers to the air density, C D0 represents the zero-lift drag coefficient, V wi refers to gust, S is the wing area, k d is the induced drag, and k n refers to the load-factor effectiveness.
The mathematical modeling of gust can be expressed as Equation (14).
where V wi is normal wind shear, V m refers to the mean wind speed and δV wi is the wind gust turbulence. The zero mean equals 0, and the standard deviation was 0.9V m for this Gaussian random variable.

Design of UAV Controller
Through an algorithm based on the 3 × 3 magic square grid, which was illustrated in Section 3, the expected position p di and expected speed of every U AV i could be calculated. Thus, the controller form of individual UAVs can be expressed as Equation (15).
where k p > 0 and k d > 0 are parameters of UAV PID controllers. The values of each item in simulations are as shown in Table 1.

Simulations of Scale UAV Grid Formations
Considering different scales of nested magic squares, this study will not illustrate them one by one. However, they share the same formation rule and topological structure, so the 11 × 11-scale UAV grid formation (121 UAVs) was used as an example. Its simulation results are as shown in Figures 18-20.   According to the UAV flying trajectory in the simulation results, it could be concluded that the UAV cluster initially moved from the unformatted sector to the formatted one. In addition, the initial flying orientation was along the x axis. From the curve graph, the cluster converged to 200 m in height within 5 s and soon entered the formatted sector. Based on the speed graph, all UAVs achieved uniform convergence in axis x, y, and z at 15 s, when the curve graph of controller output, controller input, and executive output achieved convergence. Thus, it can be seen that the 121 UAVs in that formation generally realized convergence in speed and completed the formation in 15 s. This formation is large in scale, stable in plane, and swift in convergence compared with other formations.

An Analysis on the Stability of the Visual Reference Topological Structure
In this chapter, the network connectivity index of graph theory was introduced to analyze the static stability of the visual reference topological structure of the nested magic squares. Meanwhile, a detailed description of the self-healing dynamic visual reference grid of UAV formations will be given based on the principle and argument mentioned in this study.
In this analysis, only nodes with close relations would be taken into account. For instance, in Figure 21, the UAV at square 3 in the red-dotted bordered rectangle could only refer to the UAVs at squares 4, 5, 8, and 5 in directions 8, 2, 4, and 6, respectively. If these nodes were destroyed, the UAV at square 3 would be out of the topology. In this analysis, its basic concepts include network connectiveness, network resistance to destruction, network cutpoint, network vertex cutpoint, minimum vertex cutpoint, vertex impact, network impact, and network connectivity. Their specific definitions are given as follows: Definition 1 (network connectiveness). In the network G(V,E), if there is a path from vertex v to v', the two vertexes are connected. If for every pair of vertexes (v i ,v j ∈ V) in the network G(V,E), v i and v j are connected, then G is connected.
Definition 2 (network resistance to destruction). Several vertexes or chains should be destroyed to impede the connectivity of certain vertexes. The cohesion strength and connectivity degree are often used to show the resistance to destruction.

Definition 3 (network cutpoint).
In the network G(V,E), if, for vertex v, its connected lines are deleted, the connected component of the network will be divided into two or more connected components. The vertex v will be called a cutpoint of G. Definition 4 (network vertex cutpoint). In the network G(V,E), suppose V'⊆V; if G-V' are disconnected, V' will be called G's cutpoint or vertex cutpoint. The vertex cutpoint with k vertexes will be called the k vertex cutpoint.
Definition 5 (minimum vertex cutpoint). In the network G(V,E), the vertex with the least points is called G's minimum vertex cutpoint. Definition 6 (vertex impact). In the network G(V,E), suppose that d i (i = 1,2,· · · , n). For the degrees of vertex v i , the vector L = ( 1 ; then, · · · , 1 d n ) is called the vertex impact, showing the influence of vertexes on adjacent ones. Definition 7 (network impact). In the network G(V,E), suppose A is the adjacent matrix of network G, and D is the vector showing the impact degree between adjacent vertexes. The network impact can be expressed as P = D·A, which indicates the influence of other vertexes on the network G.
Definition 8 (network connectivity). G(V,E) is an n-order connected network. If vertex cutpoints exist at G, the point of G's minimum vertex cutpoint is called its connectivity. Otherwise, n − 1 will be its connectivity. In other words, the sub-graph is still connected after k − 1 vertexes are eliminated in a network with n vertexes (1 ≤ k ≤ n − 1). However, when k vertexes are removed, the graph will be disconnected or become a trivial graph. In this way, k refers to the connectivity of G, expressed as k(G) = k.

Calculation of Network Connectivity in the Undirected Topological Diagram
To calculate the network connectivity of the visual topological diagram for different scale UAV clusters, we adopted the algorithm mentioned in the Reference [53], which is more straightforward than the traditional algorithm. The flow chart of the algorithm is as shown in Figure 22. Condition: Suppose that G has n vertexes v i (i = 1, 2, · · · , n); then, the adjacent matrix is C = (c ij ) n×n . If v i and v j are adjacent, c ij = 1. Otherwise, c ij = 0. Here, d i refers to the degree of the vertex v i .

Matlab Simulations of Network Connectivity of Nested Magic Squares' Topological Structure under Different-Scale UAV Formations
This chapter employed the matlab simulation of the network connectivity of the topological structure from 3 × 3 to 83 × 83 nested magic squares formation according to the connectivity algorithm. The regression curve equation of the connectivity was concluded, as shown in Table 2, and Figure 23.  According to the fitted curve equation, the cluster accelerated in expanding, but the network connectivity increased rather slowly. However, the network connectivity is an index to evaluate the trivial graph formed after deleting k nodes in the network topological diagram. Thus, applying nested magic squares' network topological diagrams into large-scale formations could help to greatly enhance the stability of UAV formations. The simulation results show that, at a formation size of 961 UAVs, the resulting visual reference network topology subgraph is still connected after the loss of a random 60 UAVs.

Dynamic Self-Healing of Grid Formation Based on the 3 × 3 Magic Square and the Chain Rules of Visual Reference
We calculated the network connectivity and concluded that the topological structure of nested magic squares has relatively high static stability. Still, the formation based on the 3 × 3 magic square and the chain rules of visual reference could lead to better stability. For instance, the UAV at square 4 in the dotted rectangle in Figure 13 has 16 planes that satisfy the reference principle, as shown in Figure 14. If the adjacent UAVs at squares 5,9,5,3,5,9,5, and 3 (UAVs in the blue dashed box) in directions 1-8 were destroyed due to fire attacks, the UAV at square 4 could seek reference from 8 UAVs (UAVs in the green dashed box) in its periphery. In this way, the formation could be maintained, and the regenerated topological structure diagram is shown in Figure 24. The general visual reference topology graph changes, but the UAV at square 4 in the dotted rectangle will be kept in the formation. Therefore, the formation based on the 3 × 3 magic square and the chain rules of visual reference not only has great stability but enjoys dynamic self-healing ability.

The Procedure of Matlab Simulations of UAV Formations in Battlefields
To evaluate the survival rate of a formation based on the 3 × 3 magic square and the chain rules of visual reference in battlefields, we used matlab to simulate the attacks on UAV formation in battlefields. There are six premises of the simulation experiments. First, different-scale UAV clusters will enter the enemy region and will be attacked after the formation. Second, once the grid formation is completed, all UAVs' plane height, speed, and relative distance will remain unchanged until they reach the destination. Third, each fire attack on UAVs has a random aim and is completed once it is exerted. The number of UAVs to be destroyed can be set before simulation. Fourth, UAVs out of the formation are those which lose all reference planes in the grid formation. Fifth, surviving UAVs are those which are not destroyed and for which there is at least one reference UAV. Sixth, the UAV clusters will not defend or dodge, so the stability of the formation in worst-case scenarios can be obtained. Figure 25 is the flow chart of the detailed simulation. Although the number of drones set to be destroyed is the same, there will be some variation in the number of drones out of formation as the aimed destructed areas were randomly set. For this reason, the simulation experiments were conducted 100 times with the same fight loss for the same-scale formation to obtain the average values of the UAVs which were out of formation and those which survived. Next, this study simulated the 3 × 3 to 83 × 83 grid formations and calculated the number of UAVs out of formation and surviving UAVs at 85% fight loss.

The Procedure of Matlab Simulations of UAV Formations in Battlefields
To test and verify the survival rate of formations with nested magic square topological structures based on the 3 × 3 magic square and the chain rules of visual reference in battlefields, we adopted matlab simulations to obtain the regression curve of UAVs out of the formation and surviving UAVs in different-scale formations with the fight loss set at 85%. These values can be expressed in the following equation: where H n is the remaining UAVs, M n refers to the UAVs before entering the battlefield, D n represents the total destructed UAVs, and Is o stands for the undestroyed UAVs that get out of formation. The simulation results are as shown in Table 3 and Figure 26. Table 3. Simulation results of UAV formations with 85% fight loss.

UAVs Out of Clusters (Planes)
Surviving UAV Clusters (Planes) 49 3 4  121  7  10  225  12  21  361  20  34  529  29  50  729  39  71  961  51  94  1225  62  122  1521  79  150  1849  96  182  2209  116  216  2601  136  255  3025  156  298  3481  179  344  3969  204  392  4489  230  444  5041  258  499  5625  291  553  6241  320  617  6889 355 679 The least square method was adopted to make the curve fitting simulations of UAVs out of clusters and surviving UAVs clusters with 85% fight loss, and the results are as shown in Figures 27 and 28. The regression model equation of UAVs out of clusters can be expressed as: R a = 0.0512M n + 1.1267 (18) where R a is the number of UAVs out of clusters, and M n refers to the number of clusters. According to the simulation results, the 95% confidence interval of gradients in the curve model was [0.0510, 0.0515], and that of intercepts was [0.3620, 1.8914], so the intercepts and gradients of the regression model curve equation satisfied the requirement. The R2 variance explained rate was 0.9999, proving the significance test of the regression equation with excellent fitting. The regression model equation of UAVs out of clusters can be expressed as: R b = 0.0989M n − 1.1704 (19) R b is the number of surviving UAVs, and M n refers to the number of clusters. According to the simulation results, the 95% confidence interval of gradients in the curve model was [0.0987, 0.0992], and the confidence interval of intercepts was [−1.9811, −0.3596], so the intercepts and gradients of the regression model curve equation satisfied the requirement. The R2 variance explained rate was 0.9999, proving the significance test of the regression equation with excellent fitting.
Based on the simulation results, in the 20 different-scale formation clusters based on the mentioned method, even when the fight loss accounts for 85% in each formation, only 5.1-6% UAVs would be out of the formation. In the remaining 15% undestroyed clusters, 54.4-65.7% of the surviving UAVs could continue fighting.

Conclusions
This study proposed a UAV formation method based on a 3 × 3 magic square and the chain rules of visual reference. The formation mainly adopted visual references in diverse directions, which greatly enhanced its anti-electromagnetic interference ability and the regeneration capacity of topological structures. Matlab simulations of real fights showed that when the fight loss of different-scale formations reached 85%, 5.1-6% of UAVs would be out of the formation. More importantly, in the remaining 15% undestroyed clusters, 54.4-65.7% of the surviving UAVs could continue fighting. The simulation results verified that the formation of this study has faster convergence and a larger scale in formation. Moreover, with the expansion of formation scales, the network resistance to destruction increases, leading to a higher survival rate of UAVs to maintain the formation.
Moreover, the simulation experiments were conducted without defensive measures. Otherwise, combat losses would be significantly reduced if the UAV clusters fire weapons at the enemy or have interception or attack capabilities. The formation approach in this study can provide some insight into future large-scale UAV formations for military use.