Analysis of Boid Algorithm Weights using Alignment Clustering Index

. Fish that engage in a school often exhibit unique patterns. Schooling behaviour itself has multiple benefits, among them increasing their likelihood of obtaining food and reducing the risk of predator threats. One of the methods used to simulate this behaviour is boid, proposed by Reynolds. There are three main rules that govern how each boid moves in a group: cohesion, alignment, and separation. Each rule is controlled by a weight parameter that could be changed to encourage or discourage certain rules. This study is aimed at analysing the boid weight parameters, specifically cohesion and alignment, utilizing the Alignment Clustering Index (ACI). The findings indicate that as the weight of alignment increases and the weight of cohesion decreases, boids tend to exhibit more pronounced flocking behaviour. On the contrary, as the weight of cohesion increases and alignment weight decreases, boids move as smaller subgroups comprising about 2–3 members each.


Introduction
A study on how fish behave might contribute to the development of the fisheries industry in Indonesia, especially considering that the industry accounts for approximately 2.65% of Indonesia's GDP, making it the second-largest fish producer in the entire world.One of the key sectors closely related to fish is aquaculture.Fish farming conducted in ponds involves many factors that could potentially lead to fatal failures.Understanding fish behaviour could help minimize failures while maximizing success.
Observations using cameras within these ponds could be hindered by the surrounding environment, and maintaining the equipment might also pose challenges.One potential solution that could be employed is simulation and the analysis of such simulations.Among the various methods used to simulate fish behaviour, especially in school, the boid algorithm is one of the simplest.However, it requires further changes to yield accurate results that reflect real-world behaviour.This could be accomplished by improving the existing rules and adding new ones that imitate fish behaviour [1].

Methodology
There are three basic rules that govern how each boid agent moves in the flock [2,3].First, cohesion encourages boid that is considered to move to the center of neighbouring boid in its local perception.Second, alignment encourages boid that is considered to align its velocity (that includes speed and direction) to neighbouring boid in its local perception.And the third, separation encourages boid that is considered to maintain a certain range from another boid to try to avoid them once they're in that range to avoid collision.These rules are known as classic rules, which is common extended to newly six behaviour rules [4].
Several things to consider include the fact that, in general, cohesion and alignment have the same local perception.Meanwhile, the range for separation should always be smaller than or equal to the local perception of cohesion and alignment.To imitate movement in a pond, one additional rule is added; it's called containment.Containment is a rule that encourages boids to remain within a specified container.The container itself could be anything, and in this case, a circle is used.The following diagram illustrates how each rule applies to boids.White circles represent local perceptions or range, while grey circles indicate the container radius.To determine boid position in the future, the Euler Method is utilized [5], and it could be expressed as follows, where the value of  +Δ obtained through the calculation performed by each rule that is applied to the boid agent.Simulation is performed in the personal computer ASUS TUF15 FX506HC, 11th Gen Intel Core i5-11400H ~2.7GHz;NVIDIA GeForce RTX 3050 Laptop GPU, 8 GB RAM, Operating System: Windows 11, inside Unity 2020.3.3f1LTS with 100 agents for 600 seconds.Boid agent that represents fish is a circle object with a diameter of 16 pixels.The default local perception for both cohesion and alignment has a radius of 3 body lengths (BL), this value is chosen to align with common local perception found in fish [6], and the radius of separation interaction range is 0.3 BL.The container of the containment behaviour has a radius of 20 units.Maximum speed is set to 15 units per second, with 1 unit equaling 16 pixels.The timestep used is called within the Unity engine itself with Time.deltaTime.
The variations of weights used in this research are shown in Table 1.The weights being varied are cohesion and alignment, while the weights for separation and containment are kept at 10.The unit of applied weights is arbitrary, yet the chosen value must somewhat resemble movement of the school.The addition of containment behaviour in addition to the base behaviour encourages boid to move in certain areas periodically, replicating how fish move in a pond; for this, the use of flocking index as an analysis method couldn't be done [7].Because while the school moves in a coherent manner, the index would state otherwise.For that reason, alignment clustering index (ACI) is used [8], with limitation, to analyse the boid school.ACI quantifies the degree of alignment among boid members, with value of one indicating complete alignment while zero indicating the absence of alignment.We consider a time-dependent adjacency matrix   that return 1 if the position of neighbouring boid    is in the range R of the position of boid that is considered    ; and return zero otherwise, with this matrix, the degree of collective alignment resulting from interaction, alignment clustering index   , could be expressed as follow, where Γ  , with Tr denoting matrix trace, gives the number of connections at time t while Γ  give the maximum number of possible connections for the entire boids N.

Results and discussion
As seen in Figure 2 Alongside the set of graphs that is shown in Figure 2, the mean ACI against weight variation was also obtained as shown in Figure 3.It can be observed that the mean ACI increases as the alignment weight increases.The school in the simulation with the highest alignment weight moves together to form a large group with a subgroup of approximately 15 individuals, as seen in Figure 4 (a).Meanwhile, it is observed that the school in the simulation with the highest cohesion weight moves into smaller subgroups consisting of 2-3 individuals.
How the ACI values depict the school behavior of the boid is shown in Figure 5.It can be seen from the simulation that at 3 s the boid moves into separate group (a), then a process of mergers occurs at 4 s (b), leading to a successive merger at 5 s (c), until they all merge into one big school at 6 s (d).
There is still a non-physical condition when boids collapse to single point during their motion.This can be avoided by introducing a forbidden range like a shell, that is common in simulating cell while the colony is growing [9].

Conclusion
In conclusion the use of limited ACI in boid simulation can generally demonstrate how schools form and disperse.An increase in ACI signifies the formation of school, while a decrease indicates a spread or dispersion, as shown in Figure 5.By studying on how each rule affect individual boid within the group, we can fine-tune simulation to better match the observed behavior of schools.
As the alignment weight increases, boids exhibit a tendency to cluster together as illustrated in Figure 3, where the mean ACI increases with the alignment weight.This behavior may stem from the need of every member of the group to move in same direction and at the same speed.Moreover, a high cohesion weight prompts boids to move in smaller subgroups of 2-3 individuals as evidenced in Figure 4. Here, the mean ACI decreases as the cohesion weight increases.While moving in the center of the neighbouring boids enhaces clustering, it diminishes the alignment weight.Consequently, despire a strong attraction to each other, the subgroup won't move in same direction and at the same speed hence the subgroup of 2-3 individuals.
If these studies are further continued and simulations for animals such as fish can be conducted accurately, findings of fish behaviour can be applied to optimize the fish farming sector.This could, hopefully in the future, help in the construction of ponds, assist in meeting the needs of the fish, guide fish to move to desired areas for pond management needs, or do other stuff that promotes a well and better fish growth.

Fig. 4 .
Fig. 4. Screenshots of the simulation at 600 s with (a) the highest alignment weight of 70 and (b) the highest cohesion weight of 70.

Fig. 5 .
Fig. 5. Plot of ACI against time with alignment weight at 70 and cohesion weight at 10 from 0 to 8 s, with its illustration.

Table 1 .
Weight variation for each rule used.