Swarming behaviours in animals have been extensively studied owing to their implications for the evolution of cooperation, social cognition and predator–prey dynamics. An important goal of these studies is discerning which evolutionary pressures favour the formation of swarms. One hypothesis is that swarms arise because the presence of multiple moving prey in swarms causes confusion for attacking predators, but it remains unclear how important this selective force is. Using an evolutionary model of a predator–prey system, we show that predator confusion provides a sufficient selection pressure to evolve swarming behaviour in prey. Furthermore, we demonstrate that the evolutionary effect of predator confusion on prey could in turn exert pressure on the structure of the predator's visual field, favouring the frontally oriented, high-resolution visual systems commonly observed in predators that feed on swarming animals. Finally, we provide evidence that when prey evolve swarming in response to predator confusion, there is a change in the shape of the functional response curve describing the predator's consumption rate as prey density increases. Thus, we show that a relatively simple perceptual constraint—predator confusion—could have pervasive evolutionary effects on prey behaviour, predator sensory mechanisms and the ecological interactions between predators and prey.
The sudden emergence of a cohesive swarm from the behavioural decisions of individual animals is one of nature's most striking examples of collective animal behaviour . For example, European starlings (Sturnus vulgaris) are known to form spectacular, coordinated flocks composed of hundreds of thousands of birds, seemingly without any form of leadership [2,3]. During their monthly breeding seasons, Atlantic herring (Clupea harengus) aggregate into schools comprising hundreds of millions of fish to spawn offspring . Perhaps most notoriously, desert locusts (Schistocerca gregaria) form massive swarms with billions of locusts that devastate entire agricultural zones in Africa, the Near East and southwest Asia .
While swarm-like aggregations could arise for relatively simple reasons, e.g. to converge on a common resource , in many cases swarms are formed via behavioural mechanisms that coordinate the movements of individuals to ensure group cohesion . Because swarming may incur a variety of fitness costs (e.g. increased attack rate from predators on larger swarms), considerable effort has been devoted to understanding the compensatory benefits of swarming . Many such benefits have been proposed: swarming may improve mating success [9,10], increase foraging efficiency  and provide distributed information processing abilities . In this study, we focus on swarming as a defence against predation .
Evolved swarm behaviours could protect group members from predators in several ways. For example, swarming improves group vigilance [12–15], reduces the chance of being encountered by predators [15,16], dilutes an individual's risk of being attacked [17–19], enables an active defence against predators  and reduces predator attack efficiency by confusing the predator [21,22]. Given the long generation times of many of the animals involved (months to years), it is exceedingly difficult to discern which of these benefits, if any, are sufficient to produce swarming as an evolutionary response, let alone study the properties of swarm behaviours as they evolve [22,23].
To address this challenge, we investigate the evolutionary origins of swarming behaviour in a digital system. Digital systems have previously been used to provide key insights into core evolutionary processes [24,25], and several well-known studies have adopted digital systems as a method to study swarm behaviour [26–28]. More recently, digital systems have even been used to elucidate the emergence of prey swarming behaviour as a response to predation . These previous studies have provided insight into the fundamental dynamics of swarming behaviour. However, most have not focused on isolating the evolutionary pressures that might favour the formation of swarms, and none have explored the coevolution of predator and prey behaviour. In fact, except for only a handful of studies [30–34], this literature typically has not studied Darwinian evolution as a process affecting the properties of swarms. Here, we present a model in which predators and groups of genetically homogeneous prey are coevolved in a two-dimensional virtual environment. Predators are endowed with a retina that enables them to observe prey, whereas prey are equipped with a retina that enables them to sense both conspecifics and predators. In this model, predator and prey are preferentially selected based on how effective they are at consuming prey and surviving, respectively. Swarming is a possible solution for the prey, but is not selected for directly.
While there are many different selective pressures that have been hypothesized to produce swarming behaviour, within this digital environment, we specifically study the evolution of swarming in the presence of predator confusion. In the predator confusion hypothesis, the presence of multiple individuals moving in a swarm confuses approaching predators, making it difficult for them to successfully execute an attack [21,22,35,36]. In a recent review of predator–prey systems with swarming prey, Jeschke & Tollrian  noted that predators appeared to become confused by swarming behaviour in 16 of the 25 systems reviewed. However, evidence that predator confusion is a seemingly widespread phenomenon still leaves open the question of how effective predator confusion could be as a selective force favouring the evolution of swarming behaviour.
Predator confusion is broadly interesting for two additional reasons. First, it provides an opportunity to study how swarming behaviour can in turn exert evolutionary pressures on predators, especially on the perceptual constraints that allow for predator confusion in the first place. For example, once swarming behaviour evolves in prey, predator confusion may in turn provide a selective advantage for predators that are no longer confused by swarms. Second, predator confusion may influence the functional response describing the predator's consumption rate as prey density increases , as suggested in a previous study . Understanding how pervasive mechanisms such as predator confusion affect functional response relationships is critical for accurately modelling the dynamics of predator–prey interactions over ecological and evolutionary time .
The contributions of this work are as follows. First, we demonstrate that the predator confusion effect provides a sufficient selective advantage for prey to evolve swarming behaviour. Furthermore, given prey that swarm as a result of the predator confusion effect, we show that predators could in turn be selected to evolve a frontally oriented, high-resolution visual field. Finally, we provide evidence that the shape of the predator functional response curve can be affected when prey evolve swarming behaviour in response to the predator confusion effect. Consequently, we demonstrate that predator confusion could have extensive evolutionary effects on traits ranging from prey behaviour to predator sensory mechanisms, as well as the ecological interactions between predators and prey.
2. Material and methods
To study the effects of predator confusion on the evolution of swarming, we create an agent-based simulation in which predator and prey agents interact in a continuous two-dimensional virtual environment. Each agent is controlled by a Markov network (MN), which is a stochastic state machine that makes control decisions based on a combination of sensory input (i.e. vision) and internal states (i.e. memory) . We coevolve the MNs of predators and prey with a genetic algorithm (GA), selecting for MNs that exhibit behaviours that are more effective at consuming prey and surviving, respectively. Certain properties of the sensory and motor behaviour of predators and prey are implemented as constraints that model some of the differences between predators and prey observed in nature (e.g. relative movement speed, turning agility, and, for predators, maximum consumption rate). Predator confusion, described in more detail below, is implemented as a constraint on predator perception that can be varied experimentally. The source code (https://github.com/adamilab/eos) and data (https://github.com/adamilab/eos-data) for these experiments are available online. In the remainder of this section, we summarize the evolutionary process that enables the coevolution of predator and prey, describe the sensory-motor architecture of individual agents, then present the characteristics of the environment in which predator and prey interact. A detailed description of MNs and how they are evolved can be found in the electronic supplementary material text.
2.1. Coevolution of predator and prey
We coevolve the predator and prey with a GA, which is a digital model of evolution by natural selection . In a GA, pools of genomes are evolved over time by evaluating the fitness of each genome at each generation and preferentially selecting those with higher fitness to populate the next generation. The genomes here are variable-length strings of integers that are translated into MNs during fitness evaluation (see the electronic supplementary material text).
To perform this coevolution, we create separate genome pools for the predator and prey genomes. Next, we evaluate the genomes' fitness by selecting pairs of predator and prey genomes at random without replacement, then place each pair into a simulation environment and evaluate them for 2000 simulation time steps. Within this simulation environment, we generate 50 identical prey agents from the single prey genome and compete them with the single predator agent to obtain their respective fitness. This evaluation period is akin to the agents' lifespan, hence each agent has a potential lifespan of 2000 time steps (enough time for the prey to travel approx. 400 body lengths). The fitness values, calculated using the fitness function described below, are used to determine the next generation of the respective genome pools. Parameters describing the operation of this GA are summarized in the electronic supplementary material, table S1. At the end of the lifetime simulation, we assign the predator and prey genomes separate fitness values according to the fitness functions: 2.1and 2.2where t is the current simulation time step, S is the starting swarm size (here, S = 50), and At is the number of prey agents alive at simulation time step t. It can be shown that the predator fitness (equation (2.1)) is proportional to the mean kill rate k (mean number of prey consumed per time step), while the prey fitness (equation (2.2)) is proportional to (1 − k). Thus, predators are awarded higher fitness for capturing more prey faster, and prey are rewarded for surviving longer. We only simulate a portion of the prey's lifespan where they are under predation because we are investigating swarming as a response to predation, rather than a feeding or mating behaviour.
Once we evaluate all of the predator–prey genome pairs in a generation, we perform fitness-proportionate selection on the populations via a Moran process, allow the selected genomes to asexually reproduce into the next generation's populations, increment the generation counter and repeat the evaluation process on the new populations until the final generation (1200) is reached.
We perform 180 replicates of each experiment, where for each replicate we seed the prey population with a set of randomly generated MNs and the predator population with a pre-evolved predator MN that exhibits rudimentary prey-tracking behaviour. Seeding the predator population in this manner only serves to speed up the coevolutionary process and has negligible effects on the outcome of the experiment (electronic supplementary material, figure S1).
2.2. Predator and prey agents
Figure 1 depicts the sensory-motor architecture of predator and prey agents in this system. The retina sensors of both predator and prey agents are logically organized into ‘layers’, where a layer includes 12 sensors, with each sensor having a field of view of 15° and a range of 100 virtual metres (200 virtual metres for predators). Moreover, each layer is attuned to sensing a specific type of agent. Specifically, the predator agents have a single-layer retina that is only capable of sensing prey. In contrast, the prey agents have a dual-layer retina, where one layer is able to sense conspecifics and the other senses the predator. (We note that there is only a single predator active during each simulation, hence the lack of a predator-sensing retinal layer for the predator agent.)
Regardless of the number of agents present in a single retina slice, the agents only know the agent type(s) that reside within that slice, but not how many, representing the wide, relatively coarse-grain visual systems typical in swarming birds such as starlings . For example in figure 1, the furthest-right retina slice has two prey in it (light grey triangles), so the prey sensor for that slice activates. Similarly, the sixth retina slice from the left has both a predator (dark grey triangle) and a prey (light grey triangle) agent in it, so both the predator and prey sensors activate and inform the MN that one or more predators and one or more prey are currently in that slice. Finally, since the prey near the fourth retina slice from the left is just outside the range of the retina slice, the prey sensor for that slice does not activate. We note that although the agent's sensors do not report the number of agents present in a single retina slice, this constraint does not preclude the agent's MN from evolving and making use of a counting mechanism that reports the number of agents present in a set of retina slices. Once provided with its sensory information, the prey agent chooses one of four discrete actions: (i) stay still, (ii) move forward 1 unit, (iii) turn left 8° while moving forward 1 unit, or (iv) turn right 8° while moving forward 1 unit.
Likewise, the predator agent detects nearby prey agents using a limited-distance (200 virtual metres), pixelated retina covering its frontal 180° that functions just like the prey agent's retina. Similar to the prey agents, predator agents make decisions about where to move next, but the predator agents move three times faster than the prey agents and turn correspondingly slower (6° per simulation time step) owing to their higher speed.
2.3. Simulation environment
We use a simulation environment to evaluate the relative performance of the predator and prey agents. At the beginning of every simulation, we place a single predator agent and 50 prey agents at random locations inside a closed 512 × 512 unit two-dimensional simulation environment. Each of the 50 prey agents are controlled by clonal MNs of the particular prey MN being evaluated. We evaluate the swarm with clonal MNs to eliminate any possible effects of selection on the individual level, e.g. the ‘selfish herd’ effect [30,32].
During each simulation time step, we provide all agents their sensory input, update their MN, then allow the MN to make a decision about where to move next. When the predator agent moves within five virtual metres of a prey agent it can see, it automatically makes an attack attempt on that prey agent. If the attack attempt is successful, the target prey agent is removed from the simulation and marked as consumed. Predator agents are limited to one attack attempt every 10 simulation time steps, which is called the handling time. The handling time represents the time it takes to consume and digest a prey after successful prey capture, or the time it takes to refocus on another prey in the case of an unsuccessful attack attempt. Shorter handling times have negligible effects on the outcome of the experiment, except for when there is no handling time at all (electronic supplementary material, figure S2).
To investigate predator confusion as an indirect selection pressure driving the evolution of swarming, we implement a perceptual constraint on the predator agent. When the predator confusion mechanism is active, the predator agent's chance of successfully capturing its target prey agent (Pcapture) is diminished when any prey agents near the target prey agent are visible anywhere in the predator's visual field. This perceptual constraint is similar to previous models of predator confusion based on observations from natural predator–prey systems [21,22,38], where the predator's attack efficiency (no. of successful attacks/total no. of attacks) is reduced when attacking swarms of higher density. Pcapture is determined by the equation 2.3where ANV is the number of prey agents that are visible to the predator, i.e. anywhere in the predator agent's visual field, and within 30 virtual metres of the target prey. By only counting prey near the target prey, this mechanism localizes the predator confusion effect to the predator's retina, and enables us to experimentally control the strength of the predator confusion effect. Although our predator confusion model is based on the predator's retina, it is functionally equivalent to previous models that are based on the total swarm size (figure 2, dashed line), e.g. in references [21,22,38,43]. As shown in figure 2 (solid line with triangles), the predator has a 50 per cent chance of capturing a prey with one visible prey near the target prey (ANV = 2), a 33 per cent chance of capturing a prey with two visible prey near the target prey (ANV = 3), etc. As a consequence, prey are in principle able to exploit the combined effects of predator confusion and handling time by swarming.
3.1. Effects of predator confusion
Qualitatively, we observed significant differences in prey behaviour over the course of evolution between swarms experiencing predators with and without predator confusion. Figure 3a illustrates that prey hunted by a predator without the predator confusion mechanism dispersed as much as possible to escape the predator. No replicates containing a predator without predator confusion resulted in prey behaviour that resembled a cohesive swarm. Conversely, when evolution occurred with predator confusion, prey exhibited cohesive swarm behaviour in the majority of the replicates (70% of our replicates). Figure 3b depicts one such swarm in which prey follow the conspecific directly in front of them, resulting in an elongated swarm. Similarly, figure 3c shows another swarm where the prey circle around their nearest conspecific, resulting in multiple small, cohesive swarms with the prey constantly trying to circle around each other. Both of these swarms evolved as defensive behaviours to exploit the predator confusion effect.
Furthermore, predators exhibited divergent hunting behaviours when hunting prey with and without predator confusion. As seen in figure 3a, predators that evolved in the absence of predator confusion, and hence had to contend with dispersed prey, simply tracked the nearest visible prey until it was captured, then immediately pursued the next nearest visible prey. On the other hand, predators that evolved in the presence of predator confusion, and hence were challenged with cohesive swarms, used a mechanism that causes them to attack prey on the outer edges of the swarm. This strategy is similar to a predatory behaviour observed in many natural systems [44,45], and effectively minimized the number of prey in the predator's retina and maximized its chance of capturing prey. Figure 3b demonstrates this behaviour, where the predator just captured a prey on the top-right edge of the swarm (prey capture location denoted by a black star). Videos of the evolved swarms under predation are available in the electronic supplementary material, videos S1–S5.
To evaluate the evolved swarms quantitatively, we obtained the line of descent (LOD) for every replicate by tracing the ancestors of the most-fit prey MN in the final population until we reached the randomly generated ancestral MN with which the starting population was seeded (see  for an introduction to the concept of a LOD in the context of digital evolution). For each ancestor in the LOD, we characterized the swarm behaviour with two common behaviour measurements: swarm density and swarm dispersion . We measured the swarm density as the mean number of prey within 30 virtual metres of each other over a lifespan of 2000 simulation time steps. The swarm's dispersion was computed by averaging the distance to the nearest prey for every living prey over a lifespan of 2000 simulation time steps. Together, these metrics captured whether or not the prey were cohesively swarming.
Figure 4a demonstrates that the prey hunted by a predator with only handling time (i.e. without predator confusion) moved close to each other by chance but never coordinated their movement at any point in their evolutionary history (mean swarm density ± 1 s.e. across 180 replicates: 0.69 ± 0.02). In contrast, when hunted by a predator with predator confusion, the prey coordinated their movement to remain close to each other and form a swarm (mean swarm density 12.48 ± 0.8 at generation 1200). Likewise, figure 4b shows that in the absence of predator confusion, prey evolved to maximize their dispersion (mean shortest distance 46.69 ± 0.44 at generation 1200), whereas with predator confusion, prey evolved increasingly cohesive swarm behaviour (mean shortest distance 22.54 ± 1.32 at generation 1200). Taken together, these results confirm that predator confusion provided a sufficient selection pressure to evolve cohesive swarming behaviour in this model, even though the swarming prey actually experience an increased attack rate from the predator owing to this behaviour (electronic supplementary material, figures S3 and S4).
Figure 4c shows that as a result of these evolutionary trends, the cohesive swarms that evolved under predator confusion experienced significantly higher survivorship than swarms that evolved without predator confusion (34.7 ± 0.6 and 25.54 ± 0.49 prey surviving the simulations, respectively). This increased survivorship confirms that swarming behaviour confused the predator, leading to fewer successful prey captures. We found these results robust to a variety of experimental parameters, including weaker predator confusion effects (electronic supplementary material, figures S5 and S6) and applying a minimum threshold to predator attack efficiency (electronic supplementary material, figure S7).
3.2. Evolved predator and prey behaviour
To deduce how swarms emerge in our model from individual-level behaviours, we next determined the functionality of the evolved predator and prey MNs. We accomplished this by first visualizing the MN connectivity to discern what slices of the retina and memory nodes of the MN were causally connected, then created a truth table from the MN mapping every possible input combination with its corresponding most-likely output from the MN. With this input–output mapping, we computed the minimal descriptive logic of the MN with Logic Friday, a hardware logic minimization program. We used the most-likely output for every input combination owing to the stochastic nature of MNs; therefore the functionality we determined was the most-likely behaviour of the predator or prey.
In all of our experiments, the prey at generation 1200 ignored the presence of predators and instead only reacted to the presence of conspecifics in their retina in order to follow the other prey in the swarm. This was particularly striking because it suggested that prey can evolve swarming behaviour in response to predation without the ability to sense the predators hunting them, which was suggested in a previous study . We observed that the prey evolved a wide variety of simple algorithms that exhibited a diversity of emergent swarming behaviours (videos of the swarms are available as electronic supplementary material, videos S2–S5), ranging from moderately dispersed, elongated swarms similar to starling murmurations (figure 3b) to tighly packed cohesive swarms reminiscent of fish bait balls (figure 3c).
As for the predators, the evolved behaviour we observed at generation 1200 with predator confusion appeared to be rather complex: the predators avoided dense swarms and hunted prey outside, or on the edge, of the swarm. However, the algorithm underlying this behaviour was relatively simple. The predators only watched the two centre retina slices and constantly turned in one direction until a prey entered one of those slices. Once a prey became visible in one of the centre retina slices, the predator moved forward and pursued that prey until it made a capture attempt. This process was repeated regardless of whether the predator successfully captured the prey. The simplicity of the predator algorithm and relative simplicity of the prey algorithms support the findings of earlier digital swarm studies that complex swarm behaviours can be described by simple rules applied over a group of locally interacting agents [47,48].
3.3. Effects of predator retina angle
We implemented predator confusion by imposing a perceptual constraint that reduces the probability of successfully capturing prey if one or more prey near the target prey are visible to the predator. This is meant to simulate the difficulty, arising from attentional or cognitive limitations, that a biological predator might have in choosing among multiple available prey at the moment of attack. To examine the effect of relaxing this constraint, we coevolved the predator and prey again and experimentally reduced the size of the predator's field of view. This procedure reduces the possibility that multiple prey can be detected at the moment of attack, thereby reducing the probability of confusion. For example, experimentally decreasing the predator's field of view from 180° to 60° decreases by two-thirds the area within which the presence of multiple prey can confuse the predator.
Figure 5 demonstrates that when the predator's retina only covered the frontal 60° or less, swarming to confuse the predator was no longer a viable adaptation (as indicated by a mean swarm density of 0.68 ± 0.02 at generation 1200). In this case, the predator had such a narrow view angle that few swarming prey were visible during an attack, which minimizes the confusion effect and correspondingly increases its capture rate (electronic supplementary material, figure S8). As the predator's retina was incrementally modified to cover the frontal 120° and beyond, swarming again became an effective adaptation against the predator owing to the confusion effect (indicated by a mean swarm density of 6.13 ± 0.76 at generation 1200). This suggests that the predator confusion mechanism may not only provide a selective pressure for the prey to swarm, but it could also provide a selective pressure for the predator to narrow its view angle to become less easily confused.
3.4. Effects on functional response
Predator confusion has been hypothesized to be not only a selective pressure favouring swarming, but also as a determinant of the functional response , i.e. the number of prey consumed by the predator as a function of prey density . Figure 6 supports a key prediction of functional response theory: both with and without predator confusion, the system displayed a type II functional response (a saturating effect of prey density), but when predator confusion was present the functional response showed a lower plateau (24.01 ± 0.49 prey consumed without predator confusion; 15.18 ± 0.57 with predator confusion). The fact that there was a type II functional response even in the condition without predator confusion was the result of an additional constraint present in both conditions: the handling time that was imposed on the predator after prey capture before it can attack again. Additionally, when we varied the handling time in our experiments, we found that increasing the handling time also lowers the plateau of the type II functional response (electronic supplementary material, figure S9).
We demonstrated that swarming evolves as an emergent behaviour in prey when a simple perceptual constraint—predator confusion—is imposed on the predator. Further, we found that measuring swarm density and swarm dispersion, proposed in , serves as an effective substitute for qualitatively assessing every swarm to determine if cohesive swarming behaviour is present. A diverse collection of prey swarming behaviours evolved in our model, suggesting that predator confusion could allow for a wide range of swarming behaviours to evolve. Strikingly, most evolved prey strategies used algorithms that responded to other prey, but not to the attacking predators. This raises the interesting question of what selection pressures would favour the evolution of prey that detect and respond to the predators themselves.
In contrast to the diversity of evolutionary outcomes for prey, a common behavioural strategy emerged among the predators when evolved in the confusion condition. Namely, the evolved predators focused on attacking prey on the vulnerable edges of the swarms, which is a phenomenon commonly observed in nature [44,45].
We also found that we could reduce the advantage of swarming by diminishing the predator's field of view, hence decreasing the level of confusion affecting the predator. This suggests that predator confusion could impose a selective pressure on the shape of the predator's retina: once swarming has evolved in the prey, selection will favour predators that are no longer confused by swarms. Following the trend in figure 5, we would expect selection to favour predators with a narrower, more frontally focused retina, as observed in the visual systems of many natural predators .
Modelling functional response has been an important problem in ecology , and is critical for constructing accurate models that capture the dynamics of predator–prey interactions over ecological and evolutionary time . We provided evidence that predator confusion has significant effects on functional response that are not captured in traditional models . Most of these traditional models, including the original formulation of Holling , capture the ecological interaction between predator and prey. Evolution is assumed to shape the behavioural strategies and constraints that influence predator–prey dynamics, but only recently have biologists begun to explicitly study the dynamics of predator–prey interactions over both ecological and evolutionary time . We have shown that a type II functional response evolves even when it is not directly selected for, and the shape of the functional response can be attributed to specific constraints such as handling time and predator confusion.
We demonstrated that predator confusion provides a sufficient selective advantage for prey to evolve swarming behaviour in a digital evolutionary model. This suggests that predator confusion likely contributed to the evolution of swarming behaviour in animals which were hunted by predators that relied on visual systems to track their prey. Furthermore, in this work we (i) proposed a new method to directly test hypotheses about the evolution of swarming behaviour, (ii) provided an example of how to apply this method, and (iii) demonstrated that by considering swarming behaviour in the context of evolution, we are able to make discoveries about swarming behaviour that were never previously considered. Of course, there are many other evolutionary pressures that have been hypothesized to lead to the evolution of swarming behaviour , such as the ‘selfish herd’ effect [30,32], that remain to be explored in future work. Our results suggest that digital evolutionary systems can provide a powerful tool to tease apart these various hypothesized selective pressures underlying swarm behaviour.
This work was supported in part by the Paul G. Allen Family Foundation, the National Science Foundation (NSF) BEACON Center for the Study of Evolution in Action under Cooperative Agreement DBI-0939454, and NSF grant no. OCI-1122617. Any opinions, findings and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the NSF. We wish to acknowledge the support of the Michigan State University High Performance Computing Center and the Institute for Cyber Enabled Research (iCER).
- Received April 3, 2013.
- Accepted May 13, 2013.
- © 2013 The Author(s) Published by the Royal Society. All rights reserved.