Manuscript Offprint
arXiv:2609.37885Boids of a Feather Flock Together - Evolving Prey Behaviours Under Different Predator Attack Strategies
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
Abstract
Flocking and schooling are thought to have evolved partly as defences against predation, but how prey should balance social and escape tendencies may depend on the predator's hunting strategy. We extend the predator-prey boids model of Ojo et al. (2023), itself based on Reynolds' boids, by combining six prey movement tendencies (alignment, cohesion, separation, dodge, repel and wiggle) into a single weighted acceleration update, and by reformulating wiggle as a sinusoidal manoeuvre. We then use an evolutionary strategy to optimise the six behaviour coefficients for collective prey survival against four predator hunting strategies: attack-centroid, attack-nearest, attack-random and attack-peripheral. Across five independent trials per strategy, coefficients converged within trials and mean fitness remained stable or increased, although trials often settled in different local optima. Prey survival was highest under attack-centroid and lowest under attack-nearest, in line with our hypotheses. Against attack-centroid, prey evolved individualistic predator avoidance with high escape coefficients, whereas against the other three strategies they largely kept their flock formation. Across all strategies, evolution favoured a low repel coefficient and relatively high dodge and wiggle coefficients. Our results suggest that optimal anti-predator behaviour depends on the interplay between escape tendencies and the predator's hunting strategy.
1 Introduction
Among many lifeforms, complex collective behaviour can emerge from simple social interactions, as seen in flocks of birds, schools of fish, and insect colonies. In a group, individuals influence one another and adapt their behaviour relying only on local neighbourhood information. However, such behaviour does not take place in isolation from the environment; together they form a complex, dynamical system. For example, individuals of different species or groups can interact and form predator and prey relationships. Both predators and prey have to evolve dynamic, adaptive behaviours to survive. Collective behaviours, such as schooling and flocking, may have evolved to decrease predation losses by confusing the predator or collectively organising information within a group of agents with limited information (Kunz et al., 2006). These collective behaviours can be governed by simple local rules. A classic example is the boids model by Reynolds (1987). This model simulates realistic flocking, which can be used to learn about flock behaviour in different scenarios through artificial boid simulations. One such scenario is the presence of a predator, where the trade-off between behavioural tendencies becomes crucial for survival (Palmer and Packer, 2021; Lee et al., 2006).
In this work, we evolve optimal prey escape behaviour based on local rules, under different predator attack strategies. To evolve the optimal behaviours, we again look at nature – algorithms inspired by evolution are useful for solving optimisation problems without relying on gradients (Beyer and Schwefel, 2002; Slowik and Kwasnicka, 2020). Here, we use an evolutionary strategy (ES) to optimise continuous behaviour coefficients.
What movement behaviour (in terms of relative contributions of alignment, cohesion, separation, dodge, repel and wiggle tendencies) do prey evolve to, in order to maximise the collective survival of their population under different predator hunting strategies?
We hypothesise that specific combinations of prey behaviour coefficients are optimal under different predator strategies, leading to distinct flocking and escape dynamics. Further, we expect the prey to achieve the highest survival rate under the “attack-centroid” predator strategy, as the centroid does not necessarily correspond to a specific boid, making the strategy inefficient (Demšar and Lebar Bajec, 2014). Moreover, we hypothesise that prey achieve the lowest survival rate under the “attack-nearest” strategy, as this strategy is simple but effective (von Moll et al., 2016).
1.2 Related Work
Reynolds's (1987) boids model provides the fundamental structure for simulating flocking behaviour and agent-movement, as governed by three principles: alignment, cohesion, and separation. We further build on the extension of the Reynolds' boids model of Ojo et al. (2023), who implemented two classes of boids: predator and prey. Ojo et al. (2023) further provide four predator attack strategies (attack-centroid, attack-nearest, attack-random, attack-peripheral) and three escape behaviours (dodge, repel, wiggle), which govern the prey's behaviour together with the classic boid principles. While relying heavily on the simulation implementation by Ojo et al. (2023), we make several key improvements. Most crucially, Ojo et al. (2023) analyse the prey's flocking behaviour together with one of the prey escape tendencies in isolation. Instead, we combine all three behaviours together with the flocking principles into one acceleration update vector – allowing the prey to make use of all escape tendencies simultaneously, and learn the most effective behaviour for a given predator's hunting strategy. Furthermore, in analogy with Reynolds's (1987) boids model, we treat this prey's acceleration update vector as a weighted sum of all of its components – whereas Ojo et al.'s (2023) implementation did not assign distinct weights for every movement tendency. Moreover, we further improve their wiggle behaviour, which we describe in more detail in Section 2.1, and performed sensitivity analyses on key simulation parameters.
Other studies, similar to Ojo et al. (2023) investigated predator and prey strategies, like (Demšar and Lebar Bajec, 2014) who explored the effect of different predator strategies (attack-centroid, attack-nearest, attack-peripheral) on social and individualistic prey and found flocking to be the optimal anti-predatory behaviour – they further characterised the escape patterns exhibited by the prey, similar to Lee et al. (2006).
The models described so far, relied on pre-specified behaviours and strategies with fixed parameters. We instead aim to learn prey behaviours using an ES (Beyer and Schwefel, 2002; Slowik and Kwasnicka, 2020). Previous studies similarly attempted to learn predator or prey behaviours; for example, Alaliyat et al. (2022) used a genetic algorithm (GA) to evolve the boids coefficients to achieve realistic flocking behaviour. Similarly, Hahn et al. (2019) used reinforcement learning in a predator-prey simulation to learn the prey's strategy, which resulted in flocking behaviour similar to the boids model to confuse the predator. Furthermore, Kunz et al. (2006) used an evolutionary algorithm to evolve prey behaviour while varying predator parameters. Oboshi et al. (2002) used a GA to evolve prey evasion behaviour for one attack strategy (attack-nearest) in a simulation setup similar to ours. However, all of these studies operated on a more basic level than ours, by focusing on learning general collective behaviours like flocking and swarming – instead of specific escape strategies to avoid a predator.
Few studies tried to evolve more sophisticated behaviours in a predator-prey scenario; von Moll et al. (2016) focused on evolving predator strategies in a scenario with two predators by using a GA. Similarly to our work, they evolved coefficients for a fixed set of atomic behaviours (pursue, converge, diverge, drive, flank) – however, targeting predators rather than prey. Moreover, Chen et al. (2006) use a GA to evolve coefficients in a linear combination of behaviours, consisting of the classic boid principles, as well as obstacle avoidance, following feed, and avoiding a predator. However, they only implement a direction-based escape behaviour (corresponding to “dodge”) and do not present any proper results.
To summarise, our work extends the existing literature by using an evolutionary strategy (ES) to perform continuous optimisation on the coefficients for a combination of prey behaviours to avoid predation under different predator attack strategies.
2 Methods
All analyses were performed using Python 3.11.9 on Windows. The code, result files, and sample simulation videos are available under https://github.com/ivychad/NC-Project-Code-Boids. We provide an in-depth explanation for the choice of all fixed parameters in Appendix A.
2.1 Boids Model
To study our research question, we adapted the flocking model of Ojo et al. (2024). This implementation is an extension of Reynolds's boids model (1987) – which dictates that the movement dynamics of each boid are based on three rules: alignment, cohesion, and separation. Ojo et al. (2024) extend this model by defining two types of boids, predator and prey , that each have distinct rules which govern their movement behaviour. Furthermore, they add realism to various aspects of the original model. We have refined their approach by combining the six movement tendencies into one acceleration update vector, by enhancing realism of the wiggle tendency, and by evolving the optimal coefficients for the relative contribution of each of those tendencies using an ES.
The implementation equips every boid with a position and velocity . In each iteration of the simulation, the imposed acceleration on the boid determines its dynamics of motion:
In the traditional boids model, updates in the boid's acceleration and velocity are effectively unbounded. As this is physically unrealistic, Ojo et al.'s (2024) implementation limits the direction as well as magnitude of acceleration. This implies that if the angle between the boid's current velocity and the imposed acceleration exceeds the maximum rotation angle ( ), the updated acceleration vector is limited to in the given direction ( is the rotation matrix), and rescaled to (Ojo et al., 2023). Together, this limits the turn speed of the boid. Moreover, the magnitude of velocity of the boid is bounded to . All bounds are specific to the prey or predator dynamics, and manually adjusted to model realistic behaviour, see Appendix A.
Lastly, all boids are assigned a (predator- and prey-specific) perception radius , separation radius , and a perception angle . For each movement tendency, these parameters determine which other boids are ‘seen’, and considered a ‘neighbour’ of . In the traditional boids model, this only depends on Euclidean distance , as if both predators and preys had a field of view of . However, to enhance realism, Ojo et al. (2024) also requires neighbours to be within ’s visual field (inFov( ) = true). This condition entails that is within ’s field of view (delimited by ). In addition, should not be occluded by another boid (occluded( ) = false). In this definition, neighbour occludes if they are separated by less than in ’s visual field, and is closer than . This results in excluding to be a neighbour of (Ojo et al., 2023).
2.1.1 Predator
For a predator boid with corresponding predator parameters, its acceleration is governed by either one of the following hunting strategies (Ojo et al., 2024, 2023). These strategies are in line with the attack strategies proposed by Demšar and Lebar Bajec (2014): . Its acceleration and velocity are limited as described above. The hunting strategies each characterise a specific movement behaviour:
• Attack-centroid: B targets the average position of all its neighbouring prey boids
where each of the neighbouring prey boids satisfy
• Attack-nearest: B targets the position of the nearest neighbouring prey boid
where is closest to B out of the set
of neighbouring prey boids of which each satisfies
• Attack-random: B targets the position of a random neighbouring prey boid
where is chosen randomly from the set of neighbouring prey boids of which each satisfies
• Attack-peripheral: B targets the position of the most peripheral prey boid
where is most isolated from the centroid
of the neighbouring prey boids of which each satisfies
2.1.2 Prey
For a prey boid with corresponding prey parameters, its acceleration constitutes a superposition of multiple movement tendencies. As an extension upon Ojo et al. (2024)'s implementation, we combine all movement tendencies as a weighted sum into an acceleration update vector. Each tendency's sub-acceleration is weighed by a corresponding coefficient , hereby contributing to the (normalised) direction of acceleration:
Its acceleration and velocity are limited as described above. The first three movement tendencies give rise to the boids flocking behaviour (Ojo et al., 2023, 2024; Reynolds, 1987):
• Alignment: B matches the average direction and speed of all its neighbouring boids (consistent direction flocking)
where each of the neighbouring prey boids satisfy
dist(B, ) < inFov(B, ) = true occluded(B, ) = false
• Cohesion: B matches the average position of all its neighbouring prey boids (localised flocking)
where each of the neighbouring prey boids satisfy
dist(B, ) < inFov(B, ) = true occluded(B, ) = false
• Separation: B repels the positions of all its neighbouring prey boids (preventing collisions)
where each of the neighbouring prey boids satisfy
dist(B, ) < inFov(B, ) = true occluded(B, ) = false
The remaining tendencies characterise escape manoeuvres to flee from the predator. We implemented three distinct escape behaviours (Ojo et al., 2023, 2024), as first introduced in the empirically-based Homing Pigeons Escape (HoPE) (Papadopoulou et al., 2022):
• Dodge: B dodges approaching predator boids , by turning perpendicularly in the opposite direction (direction-based escaping)
where each of the neighbouring predator boids satisfy
dist(B, ) < inFov(B, ) = true occluded(B, ) = false
• Repel: B repels the positions of all approaching predator boids (position-based escaping)
where each of the neighbouring predator boids satisfy
dist(B, ) < inFov(B, ) = true occluded(B, ) = false
• Wiggle: B wiggles by some wiggle angle and frequency if a predator is near (shake-off escaping)
where each of the neighbouring predator boids satisfy
dist(B, ) < inFov(B, ) = true occluded(B, ) = false
We enhanced (Ojo et al., 2024)'s wiggle behaviour implementation by redefining the wiggle in terms of a sine wave with specific angle and frequency, to resemble more naturalistic behaviour.
2.1.3 Simulation
To analyse the emerging movement behaviour of the boids, a field of is initialised with predators and prey. Governed by their predator- and prey-specific parameters and coefficients, movement behaviour will naturally emerge. When a predator ‘catches’ a prey (dist( , ) ), this prey is removed from the field.
2.2 Evolutionary Strategy (ES)
To study the research question at hand, we constructed an Evolutionary Strategy (ES) (Beyer and Schwefel, 2002; Slowik and Kwasnicka, 2020) around the aforementioned simulation. This ES consists of generations, of which each generation runs simulations – defining the population size. Each simulation then denotes one individual of the population, and each simulation is run for a simulation time of steps – having a fixed number of predators ( ) and prey ( ), a fixed set of predator and prey parameters, and a fixed predator hunting strategy .
Crucially, the prey coefficients are variable across simulations, and thereby characterise the movement dynamics of a unique simulation. Therefore, we define the ‘gene’ of a simulation s as their prey coefficients, .
2.2.1 Fitness
The fitness of a simulation , denoted , is defined from the prey's perspective, and reflects the number of surviving prey at the end of simulation (after time-steps):
2.2.2 Generation Updating
Given a generation of simulations (individuals), the two fittest simulations are automatically carried over to the next generation – ensuring that the most successful combination of coefficients are not lost (elitism, where elite size ). To create the remaining individuals, repeatedly two ‘parents’ are selected by means of fitness-proportional parent selection, i.e., sampled where simulation has a probability to be selected of:
Given two sampled parents , of generation , two children are created to populate generation . We employ crossover to explore the parameter space, where a random crossover point defines how the parents' genes are recombined:
Furthermore, mutation adds a small random value to each prey coefficient , by mutation rate :
The resulting prey coefficients are clipped to to keep them within the allowed range. This reproduction process is repeated for times per generation update – hereby ensuring that the next generation again counts individuals.
2.3 Experimental Design
To answer our research question, we regarded the predator’s hunting strategy as the independent variable, and the distribution of prey coefficients in over generations as the dependent variables of interest – characterising the evolution of the prey’s movement behaviour.
For each hunting strategy , we ran the ES for generations, keeping all other parameters except the prey coefficients fixed according to Table 1. For the first generation , we initialised all simulations individually with random prey coefficients, i.e., . This generation was then evolved over generations, while recording all simulations' prey coefficients , as well as their fitnesses . These coefficients were then aggregated to assess their distributions over generations – hereby assessing the prey's evolutionary response to distinct hunting strategies. Over generations, we expected the prey coefficients to converge to their optimal values, and as a result, the mean simulation fitness (collective survival rate) to rise. To account for stochasticity (while bearing our computational limitations in mind), for each predator hunting strategy we repeated this ES trial five times.
The optimal parameter settings for the main experiments (see Table 1) were largely found by trial-and-error, as motivated in Appendix A. We scrutinised , , and into more detail, as these parameters showed to have most impact in the stability of the ES. In tuning these parameters, our goal was to identify configurations that led to both an increase in collective fitness over generations and stable convergence of the prey coefficients. As we note that simulation results may heavily depend on these fixed parameter settings, the impact of varying these parameters was systematically assessed through the sensitivity analyses (see Appendix B).
3 Results
By conducting the experiments described in subsection 2.3, we recorded the dynamics of the prey coefficients – along with the fitnesses of each simulation run (i.e., ES individual) over 30 generations – yielding 31 values (initialisation included). For each predator hunting strategy, this procedure was repeated in five independent ES trials to reduce the impact of stochasticity. The resulting dynamics were aggregated to assess the prey’s evolutionary response to different hunting strategies.

(a) Attack-centroid hunting strategy,

(b) Attack-nearest hunting strategy,

(c) Attack-random hunting strategy,

(d) attack-peripheral hunting strategy,
ES 1 - simulation
ES 1 - mean
ES 2 - simulation
ES 2 - mean
ES 3 - simulation
ES 3 - mean
ES 4 - simulation
ES 4 - mean
ES 5 - simulation
ES 5 - mean
Figure 1: Evolution of the distribution of fitnesses over generations, for five different ES trials (corresponding to five different colours), per predator hunting strategy. Each dot corresponds to an individual simulation, where overlapping simulations result in darker-shaded dots. The line represents the population’s mean fitness. Note that for every ES trial, the mean fitness remains stable or rises over generations.
Generally speaking, the mean population fitness remained relatively stable (see Figure 1a), or showed a very slight (see Figure 1c and 1d) to more pronounced (see Figure 1b) increase. As no ES trial showed a downwards nor heavily fluctuating trend of mean fitness, this confirms the desired functioning of the ES. In other words, the prey managed to learn to improve their set of prey coefficients over generations, leading to movement behaviour that enhanced their collective survival rate – within the fitness limitations set by the predator's hunting strategy , which we discuss in detail below. Furthermore, we note that per hunting strategy, the mean fitness trends of the five ES trials agree – indicating that the observed collective fitness improvements are dependent on, and characteristic to, the employed hunting strategy.
In the remainder of this section, we present the results relating to each individual hunting strategy in more detail. Apart from reflecting upon the strategy-specific fitness trends, we will also assess the trends per prey coefficient – which are visualised in Figure 2, 3, 4 and 5. For these, in general, we noted that within each ES trial, the distributions of prey coefficients converge over generations. This convergence can be attributed to the ES progressing towards a local optimum. As each ES trial shows convergent behaviour of the coefficients, we therefore conclude that the coefficients' landscape allows sufficient opportunities for fitness improvement. However, this coefficients' landscape seems to contain multiple local optima – as demonstrated by some ES trials that tend to bifurcate as they unfold – resulting in the ES converging to two distinct values. This points at the coefficients' convergence being inter-dependent.
Regarding the prey coefficients' agreement between ES trials of the same hunting strategy, on the other hand, convergence patterns do not always agree. Here we observe that, depending on the hunting strategy, some prey coefficients show convergence of ES trials towards the same local optima – indicating that the coefficients' landscape is sufficiently steep to globally converge, and suggesting that the coefficient is rather crucial for the collective survival rate of the prey. For other coefficients, however, different ES converge towards different local optima – exhibiting more variability and a sparser distribution, and possibly indicating a less pronounced or more context-dependent influence on prey survival. The collected results for each hunting strategy will be assessed into more detail in the following subsections, while a comparative and comprehensive analysis, along with our interpretation for our findings, is provided in the discussion section 4.
3.1 Attack-Centroid Hunting Strategy

ES 1 – simulation
ES 1 – mean ± std (last gen.)
ES 1 – fittest simulation (last gen.)
ES 2 – simulation
ES 2 – mean ± std (last gen.)
ES 2 – fittest simulation (last gen.)
ES 3 – simulation
ES 3 – mean ± std (last gen.)
ES 3 – fittest simulation (last gen.)
ES 4 – simulation
ES 4 – mean ± std (last gen.)
ES 4 – fittest simulation (last gen.)
ES 5 – simulation
ES 5 – mean ± std (last gen.)
ES 5 – fittest simulation (last gen.)
Figure 2: From left to right, top to bottom: evolution of prey coefficients under the attack-centroid hunting strategy, , for five different ES trials – corresponding to five different colours. Each dot ( ) corresponds to an individual simulation, where overlapping simulations result in darker-shaded dots. The vertical bars indicate the population’s error margin (mean ± std) at the last generation of each ES, whereas the stars ( ) indicate the coefficient’s value of the fittest individual of the last generation.
With predators attacking the centroid of the prey flock ( ), we can observe from Figure 1a how the initial generations' fitnesses already start at near-maximal fitnesses – which is sustained as each ES unfolds. In other words, the predator's attack-centroid strategy results in little prey to be caught, with little dependence on the prey's movement dynamics.
Figure 2 shows that coefficients tend to converge within their ES run – reflected by their decreased standard deviation at the last generation. Furthermore, the coefficient distributions are generally centred around the coefficient's value of the fittest individual – indicating that fitness improvements were the driving force behind the convergence of the ES. It should be noted, however, that convergence does not always agree between ES trials. Whereas we see that the escape tendencies, i.e., dodge ( ), repel ( ) and wiggle ( ), all tend to converge towards higher values in [0.4, 1.0] – an effect which is most pronounced for the repel coefficient, as indicated by the highest agreement of error bars between ES trials.
For the flocking tendencies, i.e., alignment ( ), cohesion ( ) and separation ( ), however, the ES shows little agreement of convergence between ES trials – indicated by the lack of overlap of error margins at the last generation. Taken together, these findings suggest that individual fitness improvements are mostly realised by avoiding the predator, as opposed to changing the flock's global dynamics; this is also evident from simulation runs using the evolved coefficients for the five ES runs. Visual inspection of the fittest simulation of each ES trial revealed that for the attack-centroid strategy the prey mainly stays around the edges of the toroidal environment, while the predator moves around the centre of the environment which coincides with the centroid of the flock (given the toroidal environment). Prey consistently react to the predator by changing their direction while generally keeping the flock formation (albeit considerably less than for all other attack strategies).
3.2 Attack-Nearest Hunting Strategy

ES 1 – simulation
ES 1 – mean ± std (last gen.)
ES 1 – fittest simulation (last gen.)
ES 2 – simulation
ES 2 – mean ± std (last gen.)
ES 2 – fittest simulation (last gen.)
ES 3 – simulation
ES 3 – mean ± std (last gen.)
ES 3 – fittest simulation (last gen.)
ES 4 – simulation
ES 4 – mean ± std (last gen.)
ES 4 – fittest simulation (last gen.)
ES 5 – simulation
ES 5 – mean ± std (last gen.)
ES 5 – fittest simulation (last gen.)
Figure 3: From left to right, top to bottom: evolution of prey coefficients under the attack-nearest hunting strategy, , for five different ES trials – corresponding to five different colours. Each dot ( ) corresponds to an individual simulation, where overlapping simulations result in darker-shaded dots. The vertical bars indicate the population’s error margin (mean ± std) at the last generation of each ES, whereas the stars ( ) indicate the coefficient’s value of the fittest individual of the last generation.
When the predator attacks the nearest prey in the flock ( ), we can observe from Figure 1b how the escape for the prey is generally more difficult than in the previous attack-centroid scenario. Indeed, the initial fitness in the first generations is relatively low – showing a survival rate lower than 50% – and, despite steadily increasing in the next ES generations, it plateaus after about 10 generations, reaching an upper bound of 60 (i.e. 60% survival rate).
Figure 3 shows how the prey coefficients evolved over generations. We observe moderate to strong convergence within ES trials for most coefficients – except wiggle, as indicated by the exceptionally wide error bars. Fitness again appears to be the driving force behind strong ES convergence – as converging ES oftentimes also include the fittest individual in their error margin (which is not the case for wiggle). Between ES trials, on the other hand, we only see consistent convergence across ES trials for alignment, separation, dodge, and repel. Especially the agreement for repel is striking, as ES strongly converge both within as well as between trials. Notably, repel converges to a particularly low coefficient value of – suggesting that this is a crucial requirement for prey survival under the attack-nearest strategy. Cohesion and wiggle exhibited more variability and sparser distributions at the final generation – indicating a less pronounced or more context-dependent influence on prey survival. When visually inspecting the fittest simulation of each ES trial, we observe that for three out of five ES trials, the evolved behaviour was to stay in perfect starting formation – cruising straight ahead, without reacting to the predator, resulting in equidistant prey which were being eaten one-by-one until the end of the simulation.
3.3 Attack-Random Hunting Strategy
For the attack-random hunting strategy , the fitness improvement is less pronounced than for the aforementioned attack-nearest strategy (see Figure 1) – showing a near-negligible fitness improvement. Figure 4 demonstrates how the prey coefficients evolved over generations. We observe moderate convergence within ES trials for all coefficients – as confirmed by their medium-sized error margins. We furthermore see that between ES, the coefficients only converge towards similar value ranges for the escape tendencies – i.e., dodge,

ES 1 – simulation
ES 1 – mean ± std (last gen.)
ES 1 – fittest simulation (last gen.)
ES 2 – simulation
ES 2 – mean ± std (last gen.)
ES 2 – fittest simulation (last gen.)
ES 3 – simulation
ES 3 – mean ± std (last gen.)
ES 3 – fittest simulation (last gen.)
ES 4 – simulation
ES 4 – mean ± std (last gen.)
ES 4 – fittest simulation (last gen.)
ES 5 – simulation
ES 5 – mean ± std (last gen.)
ES 5 – fittest simulation (last gen.)
Figure 4: From left to right, top to bottom: evolution of prey coefficients under the attack-random hunting strategy, , for five different ES trials – corresponding to five different colours. Each dot (●) corresponds to an individual simulation, where overlapping simulations result in darker-shaded dots. The vertical bars indicate the population’s error margin (mean ± std) at the last generation of each ES, whereas the stars (★) indicate the coefficient’s value of the fittest individual of the last generation.
repel and wiggle. It is worth noting that repel again shows preference for lower values in [0.0, 0.4], whereas the other two tend to be in the medium-to-high range (dodge in [0.6, 1.0] and [0.4, 0.9]). For the flocking tendencies, i.e., alignment, cohesion and separation, there is higher variability and no clear agreement across ES trials. Visual inspection of the fittest simulation of each ES trial again shows a similar behaviour as for attack-nearest – with prey mostly staying in their initial formation. However, behaviour is more variable across prey, and a higher tendency for predator avoidance can be observed.
3.4 Attack-Peripheral Hunting Strategy
The fitness distribution for the attack-peripheral hunting strategy shows a comparative spread, where the fitness distribution ranges from 52 to 91 (i.e. 9 to 48 preys killed in the simulation's runtime). Despite this variability, a slight fitness improvement is achieved as the ES trials evolve. Figure 5 shows how the coefficients evolved over generations. We again observe moderate to strong within-ES convergences for all coefficients – where alignment and cohesion show the most narrow error margins. Regarding the between-ES agreement of the converged-to values, however, we observe a large variability across ES for most coefficients – as only repel shows particular preference for low ([0.0, 0.4]) values, and wiggle for higher ([0.5, 1.0]) values. The remaining coefficients all vary considerably in their convergences across ES runs. When visually assessing the ES trial's fittest simulations, we see a very similar behaviour to the attack-random results – with prey generally keeping their formation, but being less constrained than for the attack-nearest simulations. Further, we can clearly observe wiggling behaviour, which was not the case for any of the other attack strategy results.
4 Discussion
We investigated which relative contributions of six prey behaviours – alignment ( ), cohesion ( ), separation ( ), dodge ( ), repel ( ), and wiggle ( ) – prey boids converge to, for a given predator strategy, using an ES. We found that the ES was successful in maximising fitness, and converging on specific coefficients, typically driven by local improvements in the fitness landscape. The behaviours that evolved for the different predator attack strategies are largely similar, except for the attack-centroid strategy – which favours more individualistic predator-escaping behaviour – as compared to the other three strategies – which favour flocking tendencies more. Still, as Section 3 demonstrated, each strategy favoured a different combination of coefficients and differed in terms of convergence within and between ES trials. Only the ES runs for the attack-nearest strategy showed a clear improvement in fitness. For all other strategies, no relevant improvements in fitness

ES 1 – simulation
ES 1 – mean ± std (last gen.)
ES 1 – fittest simulation (last gen.)
ES 2 – simulation
ES 2 – mean ± std (last gen.)
ES 2 – fittest simulation (last gen.)
ES 3 – simulation
ES 3 – mean ± std (last gen.)
ES 3 – fittest simulation (last gen.)
ES 4 – simulation
ES 4 – mean ± std (last gen.)
ES 4 – fittest simulation (last gen.)
ES 5 – simulation
ES 5 – mean ± std (last gen.)
ES 5 – fittest simulation (last gen.)
Figure 5: From left to right, top to bottom: evolution of prey coefficients under the attack-peripheral hunting strategy, , for five different ES trials – corresponding to five different colours. Each dot (●) corresponds to an individual simulation, where overlapping simulations result in darker-shaded dots. The vertical bars indicate the population’s error margin (mean ± std) at the last generation of each ES, whereas the stars (★) indicate the coefficient’s value of the fittest individual of the last generation.
could be observed. This can be explained by the properties of the different attack strategies. The attack-nearest strategy resulted in the lowest survival rate of the prey, which is in line with our hypothesis, and furthermore agrees with previous research that found this strategy to be the most efficient (Ojo et al., 2023; von Moll et al., 2016). The optimal prey survival behaviour under this hunting strategy is to “do nothing” – that is, to stay in the initial starting formation, which perfectly equispaces the prey – preventing the predator from eating more than one prey at a time (which is a possible scenario in our simulations). Since the simulation is run for a fixed time and the predator is faster than the prey, prey essentially “wait-out” the end of the simulation. This generates a very reliable fitness. Reacting to the predator using the escape tendencies can result in higher fitness, but not reliably so – as by chance in some simulations, multiple clustered prey could be eaten by the predator in one go. In a sense, this shows how environmental context influences optimal behaviour (Palmer and Packer, 2021).
Similarly, the evolved behaviours for the other attack strategies can be understood. The attack-centroid strategy resulted in the highest survival rate for the prey – again aligning with our hypothesis and previous work (Demšar and Lebar Bajec, 2014). This can be easily explained by considering that the flock’s centroid typically does not coincide with an individual prey – resulting in the predator aiming to catch ‘empty space’. As a consequence, there is less pressure for the prey to flock, as long as they avoid the predator – as indicated by the relatively high escape coefficients. Since many possible combinations of escape behaviours can be successful for this strategy, the random initialization and all consecutive generations achieve a very high average fitness, that can hardly be improved upon due to the stochasticity inherent in both the boid’s model and ES.
The attack-random and attack-peripheral strategies place somewhere in between attack-nearest and attack-centroid – both in terms of highest achievable fitness for the prey, as well as the evolved behaviours. Both strategies are more efficient than attack-centroid, since they target and hunt actual, individual prey, but fall short of attack-nearest – which targets the closest prey, as observed by Ojo et al. (2023). This is reflected in the ES achieving maximal fitness values between the two extreme strategies. Both attack-random and attack-peripheral are rather unpredictable. For the prey, the evolved behaviour consists of generally staying in flock formation, which aligns with the findings of (Kunz et al., 2006). They turn away from the predator if it is spotted, however, they avoid sharp escape manoeuvres that break flock formation. This exploits the inefficient hunting of the predator – which regularly chooses prey that are further away – leading to long travel times during which prey are only caught by chance.
Altogether, in terms of evolved coefficients over all hunting strategies, we can highlight a general tendency towards a relatively low repel coefficient across the ES trials – while other coefficients did not present the same consistency. Other, more subtle patterns are a relatively high dodge and wiggle coefficient – which are deemed beneficial to avoid predators' attacks. This contrasts with the findings from Ojo et al. (2023), who found position-based escape (repel) to perform better than direction-based escape (dodge). This deviation could potentially be attributed to the interaction between coefficients in our research, while Ojo et al. (2023) only investigated behaviours in isolation. No clear pattern can be identified for the boids coefficients, as multiple coefficient combinations result in the observed flocking behaviour.
4.1 Limitations & Future Work
Our study has several limitations, which also pave the way for promising directions for future work. We highlight the following:
-
Environment Setting: The simulation run in our experiment assumed a 2D toroidal environment with limited size. In future research, the environment could be expanded, in terms of both size and dimensions, potentially removing the toroidal boundaries to better approximate open or higher-dimensional spaces. Furthermore, the addition of obstacles or other environmental features may vary the behaviour of the flock, thus possibly leading to interesting findings.
-
Initialisation and stochasticity: In order to account for stochasticity and isolate the effects of the behavioural coefficients, every simulation has been run starting from the exact same initial position and direction of the boids. However, to enhance the realism of those simulations and introduce stochasticity, different initial setups could be explored.
-
Computational Cost: Despite the extensive use of parallelisation in the experiment implementation, the demanding computational cost of the simulations prohibited long ES runs, and constrained our research to test ES for only generations (whereas most of the other studies run their GA for 100 or more (Olsen et al., 2018; Kunz et al., 2006)). With more computational resources, a more extensive study would be recommended to effectively assess the convergence of the ES.
-
Parameters: Given the broad parameter space, there is significant potential for further exploration. While this study fixed most parameters to maintain a realistic simulation consistent with the chosen hunting strategy, future research could examine a wider array of strategies and parameter settings, and/or combine hunting strategies, such as first attacking the centre of a flock and following up with attacking nearest prey (Demšar and Lebar Bajec, 2014). Also, introducing predator collaboration in the hunting tactic by means of increasing the number of predators, could lead to interesting prey dynamics.
5 Conclusion
We investigated to what movement behaviour the prey evolve to, in terms of relative contributions of alignment, cohesion, separation, dodge, repel and wiggle tendencies, to maximise their collective survival – under different predator hunting strategies. From the prey perspective, we conclude that flocking (relating to the coefficients of alignment, cohesion and separation) is usually beneficial, whereas the optimality of escaping (relating to the coefficients of dodge, repel and wiggle) slightly varies according to the hunting strategy adopted by the predator. From the perspective of the predators, we can conclude that attacking the centroid of the prey flock, or attacking a randomly-selected prey, is not an effective hunting strategy, while attacking the nearest prey is reliably most successful. This research serves to improve our understanding of the complex interactions between prey and predator behaviours. We encourage future research to gain deeper insights into the dynamics that were presented here.
References
Alaliyat, S., Obeidat, M., Aljarah, I., Al-Zoubi, A. M., and Faris, H. (2022). Optimization of boids swarm model based on genetic algorithm and particle swarm optimization algorithm: A comparative study. Swarm and Evolutionary Computation, 68:100982.
Beyer, H.-G. and Schwefel, H.-P. (2002). Evolution strategies—a comprehensive introduction. Natural computing, 1:3–52.
Chen, Y.-W., Kobayashi, K., Huang, X., and Nakao, Z. (2006). Genetic algorithms for optimization of boids model. In International Conference on Knowledge-Based and Intelligent Information and Engineering Systems, pages 55–62. Springer.
Demšar, J. and Lebar Bajec, I. (2014). Simulated predator attacks on flocks: a comparison of tactics. Artificial Life, 20(3):343–359.
Hahn, C., Phan, T., Gabor, T., Belzner, L., and Linnhoff-Popien, C. (2019). Emergent escape-based flocking behavior using Multi-Agent reinforcement learning. In The 2019 Conference on Artificial Life, Cambridge, MA. MIT Press.
Kunz, H., Züblin, T., and Hemelrijk, C. (2006). On prey grouping and predator confusion in artificial fish schools.
Lee, S.-H., Pak, H., and Chon, T.-S. (2006). Dynamics of prey-flock escaping behavior in response to predator's attack. Journal of theoretical biology, 240(2):250–259.
Oboshi, T., Kuroe, Y., and Uozumi, A. (2002). Evolving schooling behaviors to escape from predator. In Proceedings of the 2002 Congress on Evolutionary Computation, volume 2, pages 1410–1415. IEEE.
Ojo, M., Krajnc, M., and Adžaga, M. (2024). Collective-behavior-groupb public. https://github.com/MOj0/Collective-Behavior-GroupB. Accessed: 2025-06-23.
Ojo, M., Krajnc, M., Adžaga, M., and Kuhar, J. (2023). Predator-prey simulation using boids model. FRIteza, pages 1–4.
Olsen, M. M., Laspesa, J., and Taylor-D'Ambrosio, T. (2018). On genetic algorithm effectiveness for finding behaviors in agent-based predator prey models. In Proceedings of the 50th Computer Simulation Conference, pages 1–12.
Palmer, M. S. and Packer, C. (2021). Reactive anti-predator behavioral strategy shaped by predator characteristics. PloS one, 16(8):e0256147.
Papadopoulou, M., Hildenbrandt, H., Sankey, D. W. E., Portugal, S. J., and Hemelrijk, C. K. (2022). Self-organization of collective escape in pigeon flocks. PLoS Comput. Biol., 18(1):e1009772.
Reynolds, C. W. (1987). Flocks, herds and schools: A distributed behavioral model. ACM SIGGRAPH Computer Graphics, 21(4):25–34.
Slowik, A. and Kwasnicka, H. (2020). Evolutionary algorithms and their applications to engineering problems. Neural Computing and Applications, 32:12363–12379.
von Moll, P., Riedmiller, M., and Röfer, T. (2016). Evolutionary design of cooperative predation strategies. Artificial Life and Robotics, 21:127–137.
A Fixed Parameter Settings
We selected the parameter settings in Table 1 to be fixed during our main experiments.
| Parameter | Explanation | Value | |
|---|---|---|---|
| Boids Model | |||
| field size (px) | |||
| Predator | Prey | ||
| number of boids | 1 | 100 | |
| perception radius (px) | 3000 | {300, 750, 1500, 3000} | |
| separation radius (px) | 100 | 50 | |
| field of view, per eye (°) | |||
| maximum rotation angle (°) | 90 | 90 | |
| acceleration (px/step) | 5000 | 2500 | |
| velocity (px/step) | 500 | 200 | |
| wiggle angle (°) | 30 | ||
| wiggle frequency (rad/step) | 14 | ||
| Evolutionary Strategy (ES) | |||
| fps | simulation rate (fps) | 100 | |
| duration of a simulation (steps) | 2000 | ||
| duration of a simulation (s) | 20 | ||
| number of simulations per generation, population size | {30, 50} | ||
| number of generations | 30 | ||
| elite size | 2 | ||
| mutation rate | {0.05, 0.3, 0.7} | ||
Table 1: Fixed parameter settings relating to the Boids Model and the evolutionary strategy (ES) that were used for running the main experiments. The settings were tweaked such, that they produced naturalistic predator and prey motion dynamics, and furthermore allowed ES convergence over generations. The parameter values in light grey correspond to the settings examined in the sensitivity analyses (see Appendix B), but not selected for running the main experiments.
Relating to the Boids Model, ensured sufficient space for the boids to move around, without overcrowding the field. We chose to include one single predator () to better isolate and examine the effects of its hunting strategy on the prey, and to avoid confounding prey behaviour with responses to multiple approaching predators. The choice for prey was in line with related literature (Kunz et al., 2006), being an intuitive number to work with, and practical for fitness quantification. The parameters relating to the boids' motion dynamics, , , , , , and wiggle parameters , were tuned such, to produce naturalistic predator and prey motion dynamics. The specific settings of and were further motivated by promoting the stability of ES convergence (see Appendix B).

Figure 6: Initial layout of the predator (red) and prey (white) that was fixed for every simulation.
Furthermore, for every simulation, we fixed the initial layout of the predator (in red) and prey (in white) to be as displayed in Figure 6. Taking the predator's field of view () and the toroidal boundary conditions of the field into account, we opted for this layout to ensure that the predator has sufficient candidate prey within sight, such that its hunting strategy directly reflects in its movement behaviour. Furthermore, the evenly-spaced prey grid allows sufficient freedom for flocking behaviour to emerge. Taken together, this layout ensures that most is made out of every simulation, within duration . It is worth noting that, although the initial conditions of each simulation are deterministic, their unfolding is inherently stochastic.
For ES, we fixed fps and (in steps) such, that any change in the simulation's prey coefficients were allowed enough time to have a noticeable impact on the simulation's fitness. Within , this required a considerable amount of prey to be killed when displaying unsuccessful flocking behaviour, and conversely, sufficient chances to escape from the predator when employing successful flocking behaviour. Bearing computational time in mind, we set and such, that the ES showed to converge (see Appendix B). Relating to
was fixed in terms of steps, not seconds, as the simulation duration in terms of steps is not subject to computational power.
the generational updating, and were set such, to result in a balance between exploration and exploitation (see Appendix B).
B Sensitivity Analyses
To scrutinise the impact of varying the prey perception radius , field of view , number of simulations per generation and mutation rate on the stability of ES convergence, we performed sensitivity analyses on the aforementioned parameters. The experiments were conducted under the predator's attack-nearest hunting strategy , for generations, keeping all other parameters fixed to the settings in Table 1. For each parameter, the setting that yielded the best results was selected to be held fixed in the main experiments.
Favourable parameter settings are characterised by the population’s ability to ‘learn’ how to survive. In other words, we sought parameter settings that resulted in a rise of the simulations’ mean fitness over generations – corresponding to stable convergence of the simulations’ prey coefficients towards the fittest simulation’s value.
B.1 Perception Radius
As Figure 7 illustrates, varying the prey’s perception radius across only partly affected the stability of ES convergence within . We noted that for , the distributions of prey coefficients remained rather broadly distributed (or bifurcated) as generations evolved – reflecting a prey coefficient landscape having multiple local optima. This reflected itself as a jumpy behaviour of the fittest simulation’s prey coefficients, and furthermore the inability of the population to steadily converge towards optimal prey coefficients. Together, this seemed to impede the collective fitness to ‘learn’ to climb towards higher fitnesses.
For , on the other hand, we see a slight learning effect, as the simulations' mean fitness rises as generations unfold. Furthermore, prey coefficient convergence is seemingly more stable. Based on these results, there was no clear preference for either one of , therefore we selected for the main experiments – having the least computational load, given that higher imply more neighbours per prey.
B.2 Field of View (fov )
As Figure 8 illustrates, varying the prey’s field of view across had a minor impact on the stability of the prey coefficients’ convergence within . In the case, we observed little-to-no rise in the simulations’ mean fitness, although this was not directly reflected in the prey coefficients’ convergence – that were seemingly equally stable across all four scenarios. For the main experiments, we opted for to mimic nature – in which prey typically have larger fields of view than the predator ( ). Furthermore, this parameter setting resulted in a clear rise of the simulations’ mean fitness across generations.
B.3 Number of simulations per generation
Looking at Figure 9, varying the number of simulations per generation showed most favourable ES dynamics for . Here, the prey coefficients showed to converge more stably to the values of the fittest simulation – whereas for the distribution of the prey coefficients' values remained broad or strongly bifurcated over generations. Consequently, more simulations with suboptimal fitnesses remained within the population, whereas for they had almost all reached the fitness ceiling. For these reasons, we selected for our main experiments.
B.4 Mutation rate ( )
Looking at Figure 10, varying the mutation rate showed stronger exploitation effects – as in this scenario, generational variations through mutation were limited, we observe that the prey coefficients' distributions show little-to-no changes over generations – as variations are almost entirely dependent on crossover with just a 5% chance of mutation. This impedes exploration of the prey coefficients' landscape towards configurations that result in higher fitnesses. For , we observed the contrary. Due to the 70% chance of gene mutation, the prey coefficients struggle to converge, as their distributions remain broad over generations. Here in particular, the overemphasis on exploration withholds the mean fitness generation to steadily rise. Best prey coefficients' convergence and population fitnesses were achieved by balancing exploration and exploitation, as was the case for . Therefore, this setting was selected for the main experiments.

(a) Evolution of the simulations' prey coefficients across generations, under varying . The fittest simulation is marked as a dashed line.

(b) Evolution of the simulations' fitness across generations, under varying . The mean fitness is marked as a solid line.
Figure 7: Comparison of ES convergence in terms of the simulations' prey coefficients and fitnesses, when varying the prey's perception radius . The sensitivity analyses were run for generations. Other parameter settings were fixed to the settings in Table 1.

(a) Evolution of the simulations' prey coefficients across generations, under varying . The fittest simulation is marked as a dashed line.

(b) Evolution of the simulations’ fitness across generations, under varying . The mean fitness is marked as a solid line.
Figure 8: Comparison of ES convergence in terms of the simulations’ prey coefficients and fitnesses, when varying the prey’s field of view (per eye) . The sensitivity analyses were run for generations. Other parameter settings were fixed to the settings in Table 1.


(a) Evolution of the simulations’ prey coefficients across generations, under varying . The fittest simulation is marked as a dashed line.


(b) Evolution of the simulations’ fitness across generations, under varying . The mean fitness is marked as a solid line.
Figure 9: Comparison of ES convergence in terms of the simulations’ prey coefficients and fitnesses, when varying the number of simulations per generation (population size) . The sensitivity analyses were run for generations. Other parameter settings were fixed to the settings in Table 1.



(a) Evolution of the simulations’ prey coefficients across generations, under varying . The fittest simulation is marked as a dashed line.



(b) Evolution of the simulations’ fitness across generations, under varying . The mean fitness is marked as a solid line.
Figure 10: Comparison of ES convergence in terms of the simulations’ prey coefficients and fitnesses, when varying the mutation rate . The sensitivity analyses were run for generations. Other parameter settings were fixed to the settings in Table 1.