# Regulatory mechanism predates the evolution of self-organizing capacity in simulated ant-like robots

## Abstract

The evolution of complexity is one of the prime features of life on Earth. Although well accepted as the product of adaptation, the dynamics underlying the evolutionary build-up of complex adaptive systems remains poorly resolved. Using simulated robot swarms that exhibit ant-like group foraging with trail pheromones, we show that their self-organizing capacity paradoxically involves regulatory behavior that arises in advance. We focus on a traffic rule on their foraging trail as a regulatory trait. We allow the simulated robot swarms to evolve pheromone responsiveness and traffic rules simultaneously. In most cases, the traffic rule, initially arising as selectively neutral component behaviors, assists the group foraging system to bypass a fitness valley caused by overcrowding on the trail. Our study reveals a hitherto underappreciated role of regulatory mechanisms in the origin of complex adaptive systems, as well as highlights the importance of embodiment in the study of their evolution.

## Introduction

The evolution of complexity is one of the most striking characteristics of life throughout its hierarchy1,2. The resulting complexity, that is, the system’s increase in its components and multifaceted interactions among them, often entails adaptation to the environment, known as complex adaptive systems3,4,5. At the organismal level, theoretical works based on Fisher’s geometric model of adaptation predict that a population of organisms climbing a hill in a fitness landscape evolves a complex polygenic trait based on a few major genes and many minor genes6,7,8,9. Typically, the advent of major genes with large phenotypic effects is followed by the subsequent evolution of minor genes with small phenotypic effects.

Complex adaptive systems beyond the single organismal level, such as multicellularity and social organization, show similar multi-component regulations: The systems seem to take a layered form in which their core components, often considered as evolutionary innovation and hence with large phenotypic effects, are buffered by additional, regulatory components with relatively small phenotypic effects10. The core components generally involve interactions between group members that have synergistic effects on the performance of the group, while the regulatory components support the function of core components (note that the regulatory is relative to the core). Self-organization itself does not guarantee adaptation10,11,12, and previous studies have shown how supplementation of accessory regulation to core components of self-organization can lead to variable system outputs10,13,14,15,16 and make the systems adapt to species-specific17,18,19 or within-species changing environments19,20. Being biologically implemented, these adaptive modifications should be attributed to the evolution of regulatory components that improve the self-organizing property of core components. However, the underlying tenet of gradual evolution has often been hampered by the classic problem of maladaptive intermediate, which raises a concern that a system equipped only with a core component (i.e., no regulatory components) may suffer lowered fitness compared to those without the core component (see Discussion). Therefore, deciphering the evolutionary order of appearance of regulatory components relative to core components will contribute to a better understanding of the evolutionary mechanisms that add complexity to natural biological systems21.

In this study, we address this issue by considering social insect colonies as a model system. Social insects stand at one of the pinnacles of biological complexity. Their colonies are characterized by highly coordinated systems, often likened to swarm intelligence, in which microscopic interactions of nestmate individuals collectively produce diverse macroscopic phenomena10,22,23,24. A typical example is found in mass foraging by ants with trail pheromones25,26. The core component of this system is indirect pheromone communication among nestmates according to the following algorithm: Once a worker finds food, she puts a chemical marker on the ground while carrying the food to her nest; nestmate workers are recruited to the marker and follow the trail toward the food, and lay the same marker to reinforce the trail. The system is strengthened by the balance between positive (trail reinforcement) and negative (trail decay) feedbacks depending on changing availability of pheromones, which was the inspiration of Ant Colony Optimization (ACO27), a computational metaheuristic for solving hard combinatorial optimization problems.

We took a constructive approach with both robotic and computational systems that mimic this foraging system, focusing on its logistic aspects28,29. The use of artificial systems mimicking collective behaviors of animals can provide not only controlled experiments that would be impossible in real organisms, but also greater realism through embodiment, which is often abstracted in analytical and purely simulational studies30,31,32,33. Examples include the demonstration of evolutionary emergence of cooperative behaviors34,35,36,37,38 and rigorous testing of kin selection theory39. During the development of the real robotic system, we faced a problem of how to deal with overcrowding on the trail. Because the use of the trail inevitably puts robots (as it does ants) into traffic-jam-like overcrowding, an accessory regulation that supports efficient pheromone communication is required in both systems. As a solution to the robotic overcrowding, we heuristically introduced a set of collision-avoidance behaviors in the robots, which improved their group-foraging performance29,40. These behaviors constitute an overall traffic rule, such that inbound (food-to-nest) robots are always given priority over outbound (nest-to-food) robots. Interestingly, similar collision-avoidance rules have been reported in some ants41 (see Discussion). Although the ants and our robots are obviously different in many respects, the two systems share the same property of layered complexity: the core component (pheromone-mediated group foraging) is supported by regulatory traits (traffic rule that improves the group foraging). Therefore, we asked how such complex adaptive systems that would have been malfunctional without accessory regulations were achieved through adaptive evolution.

Using a simulated system that precisely modeled the dynamic properties of real robots29 and a field setup that mimics the foraging of arboreal ants on tree branches or of subterranean ants and termites inside tunnels, we first confirmed that the algorithm of pheromone communication alone was not sufficient to establish effective recruitment due to the overcrowding on the pheromone trail. The additional traffic rule was required to solve this problem by keeping the robots from being stuck on the trail. Next, we performed evolutionary population genetic simulations that allowed for mutation and selection to occur simultaneously in pheromone responsiveness and collision-avoidance behaviors of the robots. In accordance with the conventional notions of polygenic traits, it initially seemed reasonable to assume that such regulations evolve after the system’s core component has been established, simply because the former rely on the latter for their functions. However, in most simulation runs, the priority-giving behavior for collision-avoidance did not arise as a consequence of pheromone communication, but arose in advance, taking the form of selectively neutral behaviors in the absence of the self-organizing capacity. The behaviors then assisted the pheromone responsiveness trait to arise and become fixed in the population. Finally, we confirmed the above results with a population genetic analysis hybridized with simulated distributions of fitness values.

## Results

### Experimental setup

Our virtual robot swarms, each consisting of 30 simulated robots, searched for the food located on one end of a rectangular field (900 mm × 9000 mm) surrounded by walls and enclosing their nest-site on the other end (Fig. 1a). The algorithm for group foraging behaviors of the robot swarms29 is described as state transitions of each robot among three behaviors: S1, searching; S2, carrying food (inbound) and recruiting (laying scent); and S3, being recruited (outbound, following scent), which work as follows (Fig. 1b): once a searching robot (state S1) finds food, it starts to secrete a chemical compound on the ground while returning to its nest with a virtual food item (state S2). If the robots can detect the resulting chemical trail as a trail pheromone, they then follow the trail toward the food (state S3, regarded as successful recruitment). State S3 is functional only in the presence of the ability to detect pheromones. As an accessory regulation, we implemented a collision-avoidance behavior: When two robots collide, both take one of two reactions: ‘Stay’ (stop moving for a given time) or ‘Leave’ (move backward by a given distance). We assumed that the robots’ reactions depend on their state (for different assumptions, see Discussion). When colliding robots with different states take different reactions, they can be regarded as obeying a traffic rule, i.e., the robot with the reaction ‘Leave’ gives priority to the robot with the reaction ‘Stay’ (Fig. 1c). To allow for the robotic swarms to evolve, we made a simple assumption that each robot has its own haploid genome consisting of four loci, b1, b2, b3, and p, each of which has a binary allelic state (0 or 1). The resulting multilocus genotype is described as {b1,b2,b3;p}. The locus bi (i $$\in$$ {1, 2, 3}) defines the collision-avoidance behavior (i.e., Stay = 0, Leave = 1) taken by the robot with state Si. That is, if a robot is currently in state Si, then its collision behavior is bi. The locus p defines the ability to detect pheromone.

### Measuring fitness

We measured biological fitness of simulated clonal swarms resulting from their multilocus genotypes ({0,0,0;0} – {1,1,1;1}, 24 = 16 in total, Supplementary Table 1) to map a multidimensional fitness landscape. The total number of times the robots go back to their nest from the food in a given time (see Methods) was considered as a measure of swarm fitness. The ability to detect pheromone (p = 1) alone did not result in higher fitness (Fig. 2), although recruitment (S3) occurred (illustrated as the presence of orange bars in Supplementary Figure 1). The reaction ‘Leave’ at locus b1 contributed to the fitness increase regardless of the presence of pheromone responsiveness. Interestingly, particular sets of behavioral genotypes together with the pheromone responsiveness remarkably improved the swarm fitness, which was achieved through successful recruitment. Among the 16 multilocus genotypes, the genotype {1,0,1;1} showed the highest swarm fitness, in which a traffic rule was established with outbound robots (b3 = 1) giving priority to inbound robots (b2 = 0) on the pheromone trail. This result was consistent with our previous real robot experiment40. To confirm that the traffic rule helped the swarms to avoid overcrowding, we counted the number of collisions during each simulation run. The traffic rule on the pheromone trail (b2 = 0, b3 = 1), together with b1 = 1, strengthened the pheromone communication by reducing the occurrence of collision (Supplementary Figure 2).

### Evolutionary simulations

We next conducted population genetic simulations to trace an evolutionary trajectory of the robotic population that initially had the genotype {0,0,0;0}, that is, without pheromone communication and priority-giving behaviors. For simplicity, all robots in a single swarm were assumed to have the same genotype, and genetic variation was permitted only among swarms. In terms of sociobiology, only a single robot in the swarm clonally (with mutations) produces foundress robots of the next generation depending on the swarm fitness, each of which then clonally reproduces (without mutations) to form a new swarm. Consequently, the average relatedness of nestmates within a swarm is strictly 1.

Throughout the simulation replicates, as expected, the populations eventually became fixed at the genotype {1,0,1;1}; that is, the swarms successfully evolved the pheromone-mediated collective behavior together with the traffic rule (Supplementary Movie 1). Then we inspected the detail of each evolutionary trajectory. The population of swarms first became dominated quickly (frequency ≥ 0.985, fixed in most cases, Supplementary Table 2) by the genotype {1,0,0;0}, in which the reaction ‘Leave’ by randomly searching robots (b1 = 1) was not related to pheromone communication (Supplementary Movie 1). Starting from the population dominated by the genotype {1,0,0;0} and assuming the shortest path, the robot swarms had to experience 0 → 1 mutations at both loci b3 and p before fixation of the genotype {1,0,1;1}. Surprisingly, in most (44/50) of the simulated genealogies leading to the final genotype {1,0,1;1}, the 0 → 1 mutations occurred first at the behavior locus b3, followed by the pheromone-responsiveness locus p (Fig. 3a). The intermediate genotype {1,0,1;0} never became fixed; it served as the source of the final genotype when it had an intermediate (0.005–0.685) frequency in the population (Fig. 3b, Supplementary Table 2). Among the rest of the simulated genealogies, five had the 0 → 1 mutation occurring first at locus p and then at locus b3. The intermediate genotype {1,0,0;1} remained at a low frequency (0.01–0.02). One genealogy did not take the shortest path from {1,0,0;0} to {1,0,1;1}; its sequence was {1,0,0;0} → ​{1,1,0;0} → ​{1,1,1;0} → ​{1,1,1;1} → ​{1,0,1;1}. Mutations at the behavior loci were observed both before and after the 0 → 1 mutation at locus p. The irregularity can be explained by an additional 0 → 1 mutation at locus b2 before the 0 → 1 mutation at locus b3 while the dominant pattern of evolutionary precedence of b3 = 1 over p = 1 remained intact.

### Interpreting the evolutionary process

The observed bias toward evolutionary precedence of the regulatory trait over the core pheromone-responsiveness trait can be explained using the fitness landscape as follows (Fig. 4a): One of the two possible intermediate genotypes, {1,0,0;1}, actually had lower swarm fitness than the genotype {1,0,0;0} because of overcrowding on the pheromone trail (Supplementary Movie 1), whereas the other intermediate {1,0,1;0} gave the same fitness in principle because locus b3 gives a selectively neutral trait by definition, as long as the pheromone-responsiveness is absent (i.e., p = 0) (Supplementary Movie 1). Consequently, the genotype {1,0,1;0} is more likely to arise first.

The evolutionary process with selectively neutral or even inferior intermediates is known as stochastic tunneling42 (see Discussion). To evaluate how common the observed evolutionary precedence of the regulatory trait (45/50; note that we tentatively included the irregular genealogy described above) is, we applied the population genetic formulation of stochastic tunneling43 that analytically yields the point estimate of waiting time to fixation of the genotype {1,0,1;1}. Starting from the population fixed at the genotype {1,0,0;0}, the evolving population takes one of the two possible shortest evolutionary paths—that is, the path with the intermediate genotype {1,0,1;0} (b3 = 1 first) and that with the alternative intermediate {1,0,0;1} (p = 1 first)—and the realized path could be predicted as the one with the shorter waiting time by comparing respective estimates. Among the parameters of the analytical model were the relative fitness (compared to the original genotype {1,0,0;0}) of the neutral intermediate {1,0,1;0}, the inferior intermediate {1,0,0;1}, and the final genotype {1,0,1;1}, which had to be derived empirically from the evolutionary simulations. Therefore, we incorporated resampled distributions of relative mean swarm fitness (Fig. 4b) into the analytical model (see Methods and Supplementary Note 1 for details).

We generated 1000 sets of 50 evolutionary outcomes that the populations were expected to show. The 50 outcomes were typically dominated by those with the intermediate genotype {1,0,1;0}, and their frequency distribution (calculated over the 1000 sets) included the observed frequency (45/50) at the borderline of the 95% interval between the 2.5th34 and 97.5th44 percentiles (Supplementary Figure 3). The rare outcomes with the inferior intermediate (i.e., the precedence of pheromone responsiveness) were explained by the stochasticity in the swarm fitness that sometimes resulted in the higher mean relative swarm fitness of this genotype than of the neutral intermediate (Fig. 4b). Moreover, the waiting time to fixation averaged over the 50 runs (157.68 generations) again fell within the 95% interval between the 2.5th (145.54) and 97.5th (354.76) percentiles of the distribution of the mean waiting time (Supplementary Figure 4). These analyses support the view that the phenomenon observed in our evolutionary simulations is well-captured quantitatively by the theory of stochastic tunneling, and that the evolution of self-organizing capacity in our robotic system was facilitated by this evolutionary process.

## Discussion

One of the long-standing debates in evolutionary biology ever since Charles Darwin is based on the observation that the complexity of life we can find today seems too sophisticated to be achieved through gradual evolution44,45. Advocates of saltationism or macromutationism claim that gradualism cannot account for the incipient stages of complex adaptive traits because the intermediate forms must be maladaptive45. The debate has consequently motivated further work on the genetic and developmental basis of organismal complexity, leading to the rise of present-day evolutionary developmental biology (reviewed in e.g., refs. 46,47). The current consensus is that both views are correct depending on systems, and that the real evolutionary processes are fairly complex48. These contrasting views on the origin of complexity can also be applied to the evolution of social systems, which motivated our present study. In our robotic swarms, the intermediate maladaptive stage corresponds to the pheromone-based recruitment without the traffic rule. By taking a standard population genetic approach, we demonstrated that the resulting fitness valley can be dynamically bypassed through a selectively neutral alternative, that is, cryptic priority-giving behavior without pheromone-based recruitment. Here, the regulatory mechanism was not an evolutionary follower of the core component; instead, it preceded the establishment of the core component and assisted it. The evolutionary precedence of some regulatory mechanisms originated as selectively neutral traits (neutral from their regulatory functions) might be a general component feature of complex adaptive systems, as long as the systems’ core components alone are maladaptive and the accessory regulations rely for their functions on the core components. It does not rule out the possibility that the regulatory mechanisms can arise after the establishment of the core components. The resulting layers of accessory regulations should contribute to the complexity of life.

The role of the cryptic regulatory mechanisms can be understood by employing the structuralist concept of exaptation49, a formal definition of so-called preadaptation. Exaptation refers to the evolution of traits that had originated by the selective advantage other than their current use (pre-aptation) or that had originally been non-adaptive (non-aptation or spandrel); both were subsequently co-opted into current adaptive use. The regulatory behavior of our system may provide an example of non-aptation because, by definition, the trait b3 = 1 was selectively neutral at its origin. A biologically realistic interpretation of this selective neutrality in the absence of pheromone communication would be that the trait b3 involves the behavior that is specifically released when colliding with the food-laden agent (i.e., with state S2). It should be noted here that we can also consider different genetic coding of the three behavioral traits (b1b3). On the basis of another biologically reasonable assumption that the trait b3 = 1 (or b2 = b3 = 1) is a byproduct following the expression of b1 = 1 (i.e., pleiotropy), again we can expect preadaptive precedence (or spandrel, i.e., a neutral byproduct of previous adaptation in other contexts50) of the regulatory mechanism in this foraging system, otherwise the fitness valley would arise owing to overcrowding (Supplementary Note 2).

In our simulations, the bypassing of the fitness valley was driven by the evolutionary process called stochastic tunneling. This was originally proposed as a mathematical description of cancer initiation42,51, and the same mechanism was independently found in an analysis of the evolution of cis-regulatory elements (genetic regions that regulate gene transcription in the physical vicinity of the target gene)52. Taking cancer initiation as an example, its somatic evolution is characterized by a two-step process leading to biallelic loss-of-function mutations at the tumor suppressor gene. The first mutation at a single allele is either selectively neutral or disadvantageous (through chromosomal instability) for cell proliferation, and the second mutation at the counterpart allele of this diploid locus triggers increased proliferation as tumor cells. Through stochastic tunneling, the population of cells can shift from the all-intact state to the all-tumor state without experiencing the all-intermediate state. The situation is very similar to our model, except that the genes involved are more than one in our clonal robots. The population of robot swarms favored the neutral intermediate over the disadvantageous alternative, which was easily explained by the comparison of waiting time estimates between the two tunneling routes. The role of stochastic tunneling in the origins of more complex systems, especially those with recombination21, epistasis53,54,55, or indirect genetic effects54,55, deserves further study.

A potential concern about applying our rather retrospective approach (i.e., the genetic encoding was made after the best set of behaviors thus far had been known heuristically, see Introduction) to real complex adaptive systems would be that biological systems cannot tell a priori what should serve as regulatory mechanisms before the emergence of a core system. Nevertheless, we can predict that complex adaptive systems should be found more frequently in systems allowing more capacity for neutral genetic variations as a source of exaptation. The role of cryptic genetic variations in the emergence of evolutionary novelty is well acknowledged in current evolutionary biology56. Such cryptic variations would help a primitive system to avoid crossing the fitness valley by providing selectively neutral alternatives. In the context of social organizations, a previous theoretical study predicted that genes with social effects should harbor more variations within a population owing to weaker selection pressure on indirect genetic effects57. Meanwhile, computational studies that focused on the architecture of biological systems, such as genetic and neural networks58,59,60 and secondary structures of RNA molecules61, have acknowledged the importance of neutral variations as evolutionary capacitors. By highlighting the importance of exaptation and neutral genetic variations for complex adaptive systems, our study bridges an apparent gap between computational and macro-biological studies on the evolution of biological self-organization. Phylogenetic comparative methods might help to test our prediction empirically by reconstructing multi-trait evolutionary processes that lead to extant complex adaptive systems.

In our evolutionary model, there is another exaptation regarding the pheromone-communication ability. That is, we implicitly assumed that the inbound robots had already secreted some chemical substance on the ground, and that pheromone communication was achieved upon acquisition of the detection ability as a cue (i.e., 0 → 1 mutation at the pheromone-related trait p). In the study of animal communication, there are two models describing the evolutionary origin of communication: sender-precursor model and receiver-precursor model62. The former model assumes that there was initially a material (visual, chemical, or tactile) emitted from the sender-to-be, which are then utilized by the receiver as a cue. We followed this scenario by assuming that there were already some chemicals secreted by inbound agents. The latter model assumes that there was initially a sensory characteristic of the receiver-to-be agents (also known as sensory bias), which are then co-opted into the biased communications with specific interactants. Although it is beyond the scope of our present study, our bottom-up approach with embodied agents would also be suitable to study the evolutionary origins of communication systems (see ref. 35).

Our simulated robots favored the traffic rule under which inbound robots had priority over outbound robots on the trail. In real social insects, previous studies reported traffic-rule-like behaviors shown by ant foragers along their foraging trails (reviewed in ref. 41). Examples include three-lane bidirectional traffic flow63, alternating clusters of inbound and outbound ants facing a traffic bottleneck64, inbound leaf-laden ants followed by unladen ants65, and alternative route selection through inbound–outbound behavioral interactions at the junction66. In those examples, macroscopic traffic flow emerges from microscopic behavioral rules where inbound ants are given priority over less-loaded outbound ants. Using embodied robots supplied with virtual food, our study demonstrated that such traffic rules do have an adaptive significance for efficient logistics, in addition to their mechanism (proximate cause) in which real inbound ants have less maneuverability due to food load41. It should be noted here that the rectangular field setup used in our simulations was not the primary factor giving an advantage of having the traffic rule. Our previous study using real robots40 showed that the same traffic rule {1,0,1;1} remained essential for the pheromone-mediated group foraging with fewer (n = 4–10) robots on a field of different shape (3600 mm × 3600 mm). Our field setup might be applied not only to the group foraging behaviour (see Introduction) but also to the traffic flow inside ant nests, where numerous ants have to manage overcrowding along their underground galleries. The effects of robot density and field shape on the evolutionary order of core (p = 1) and regulatory (b3 = 1) components deserve further study.

To obey the traffic rule, the trail-following robots (i.e., with state S3) need to put the priority-giving behavior temporarily above the core pheromone responsiveness. This temporal irregularity becomes evident when the reaction ‘Leave’ often moves the robot away from the pheromone trail (Supplementary Movie 1). The priority-giving behavior is released after the direct experience of collision with inbound robots, while the pheromone responsiveness can be regarded as following socially available information of food location. Therefore, the adaptive use of the traffic rule might be a situation whereby the robots flexibly prioritize direct social information (collision suggesting traffic jam) over indirect social information (pheromone trail) depending on their internal state during behavioral decision-making. Recent studies have revealed how ants make decisions under such conflicting information (reviewed in ref. 67). The use of multiple information sources and their integration during collective decision-making would be of particular interest in future study.

An advantage of taking constructive approaches with embodied agents is that we can incorporate physical consequences derived from properties of the agents and their abiotic and biotic interactions. Some of them might manifest as physical constraints hindering adaptation, such as the overcrowding we observed, but a more positive aspect would be greater, often unpredictable, degrees of freedom (or evolvability) supplied to the dynamic systems. Previous studies of experimental evolution with swarm robots have revealed various aspects of such consequences, including coordinated behaviors (e.g. ref. 68) and self-organized division of labor69 (see also Introduction). The evolutionary convergence of traffic rules between ants and our robots, together with those earlier studies, clearly indicates that a collaboration between macro-biology and swarm robotics provides a promising avenue to elucidate the evolutionary and developmental processes leading to the complexity of social life, as well as a hopeful engineering application to solve our real-world problems.

## Methods

The basic algorithm for the pheromone-mediated group foraging behavior and the priority-giving behavior, as described in Results, were originally designed to control real robots29. The real robot system, named ARGOS-02 (‘Ant’elligent Robot Group Operating System, note that our system is different from another swarm robot system named ARGoS70), used an aqueous solution of ethanol as the trail pheromone. ARGOS-02 is a modified version of the original ARGOS-0128, using two sets (instead of the original one) of micro-pumps and tanks to secrete the pheromone at arbitrary concentrations. The agent-based simulation platform was developed in-house, written in C28,29,40 (see also Code availability). Dynamic properties of this simulated system have been well validated by comparing with real robot systems28,29,40. Briefly, this system is intended to emulate shape characteristics of our robots (rigid-body objects with 150 mm and a maximum speed of 100 mm/s) and the experimental field, evaporation dynamics of the pheromone (with coefficients of evaporation and diffusion) and its sensing, and the collision process described by simple contact of a robot with walls and other robots (for a full description, see ref. 29).

### Experimental setup

A simulated swarm consisted of n = 30 robots, which were provided with a rectangular field of 900 mm × 9000 mm surrounded by walls, together with a food source (ø 300 mm) and a nest (ø 1000 mm) on opposite ends (Fig. 1a). The food emitted light, which a robot could detect within a radius of 600 mm from its center. The nest location was made available to all robots by provision of an infrared light directly above it. The initial positions of the robots were set randomly on the field, and each swarm was allowed to forage for 12,000 time steps (20 min for the real robots).

### Evolutionary simulations

The evolving population consisted of N = 200 non-interacting swarms (i.e., no resource competition among swarms). We assumed a Wright–Fisher population with a constant size. The genetic coding of the traits is described in the main text. As a prior state to the pheromone-related trait p, we implicitly assumed that the inbound robots had already secreted some chemical substance on the ground, and that pheromone communication was achieved upon acquisition of the detection ability as a cue (see Discussion). A swarm was selected as a (clonal) parent for the next generation’s swarm in proportion to its fitness, so that a swarm with the better foraging performance had the greater chance of producing offspring clonally (i.e., being selected as a parent swarm in the simulations). In the next generation, bi and p of all genomes in an offspring swarm mutated to the other value (0 → 1 or 1 → 0) with a probability µ = 0.001. The low value of mutation rate, compared to conventional evolutionary simulation studies used in computer sciences, was intended to approximate to real biological systems (i.e., it should take relatively long generations for a polygenic system to reach the optimal state). On the basis of the preliminary observations that the genotype {1,0,1;1} is uninvadable by the other genotypes, each simulation run continued until the population became fixed at that genotype. Genotypes of the parent swarms of the genotype {1,0,1;1} that became fixed were determined by direct assessment of the genealogies.

### Analytical solutions of time to fixation

We considered the time until the genotype became fixed {1,0,1;1}, starting from the population of the genotype {1,0,0;0}. The time to fixation can be obtained analytically by using population genetic formulations43. Four kinds of genotypes were considered: the original genotype {1,0,0;0}, the two intermediates {1,0,1;0} (neutral) and {1,0,0;1} (inferior), and the final genotype {1,0,1;1}.

We calculated the time (generations) until the final genotype became fixed, starting from the population with the original genotype. The original-to-intermediate transition and the intermediate-to-final transition at a swarm occur with the same probability µ, which corresponds to the mutation rate of a single locus. We obtained distributions of the relative fitness (compared to the original) of the neutral intermediate (denoted by r0), the inferior intermediate (r), and the final genotype (a) using data from our evolutionary simulations, as described in Supplementary Note 2.

The probability of tunneling can be given by T = [1 – U(rx)](1 – v1), where N is the number of swarms, U(rx) is the probability of fixation of the intermediate genotype with relative swarm fitness rx (x $$\in$$ {0, –}), and v1 is the probability of non-appearance or extinction of the final genotype lineage arising from a single swarm of the intermediate genotype with relative swarm fitness rx43. The expected time until the final genotype is given by

$$E\left[ t \right] = \frac{T}{{\left( {T + S_1} \right)^2}} + \frac{{S_1(S_1 + S_2 + T)}}{{S_2\left( {T + S_1} \right)^2}}$$

where $$S_1$$ and $$S_2$$ describe the probabilities that primary and secondary mutations, respectively, become fixed. In the equation, the first term represents the contribution from tunneling paths (original → final) and the second term the contribution from the sequential paths (original → intermediate → final)43. Given that a shorter time results in a higher probability of realization, the evolutionary paths are expected to go through the intermediate genotype with the highest relative fitness when there are more than one candidate tunneling paths. See Supplementary Note 1 for details.

The main codes of the simulations were implemented in C and R. To shorten the calculation time, we used parallel computation realized by OpenMP. The evolution of swarms was managed by Python programs. For the analytical calculation, we used Mathematica, especially for large matrix calculations.

### Code availability

The source code is available at https://github.com/SWARM-ARGOS/Harsh_Mistress/.

## Data availability

The main outputs of evolutionary simulations are shown in Supplementary Table 2. The raw data generated are available from the corresponding author on reasonable request.

## References

1. 1.

Maynard Smith, J. & Szathmáry, E. The Major Transitions in Evolution (W. H. Freeman/Spektrum, Oxford, New York, 1995).

2. 2.

Carroll, S. B. Chance and necessity: the evolution of morphological complexity and diversity. Nature 409, 1102–1109 (2001).

3. 3.

Holland, J. H. Hidden Order: How Adaptation Builds Complexity (Basic Books, New York, 1996).

4. 4.

Levin, S. A. Ecosystems and the biosphere as complex adaptive systems. Ecosystems 1, 431–436 (1998).

5. 5.

Bonabeau, E. Social insect colonies as complex adaptive systems. Ecosystems 1, 437–443 (1998).

6. 6.

Orr, H. A. The population genetics of adaptation: the distribution of factors fixed during adaptive evolution. Evolution 52, 935–949 (1998).

7. 7.

Orr, H. A. Adaptation and the cost of complexity. Evolution 54, 13–20 (2000).

8. 8.

Barton, N. H. & Keightley, P. D. Multifactorial genetics: understanding quantitative genetic variation. Nat. Rev. Genet. 3, 11–21 (2002).

9. 9.

Orr, H. A. The genetic theory of adaptation: a brief history. Nat. Rev. Genet. 6, 119–127 (2005).

10. 10.

Camazine, S. et al. Self-Organization in Biological Systems. (Princeton University Press, Princeton, 2001).

11. 11.

Hoelzer, G. A., Smith, E. & Pepper, J. W. On the logical relationship between natural selection and self-organization. J. Evol. Biol. 19, 1785–1794 (2006).

12. 12.

Johnson, B. R. & Lam, S. K. Self-organization, natural selection, and evolution: cellular hardware and genetic software. Bioscience 60, 879–885 (2010).

13. 13.

Kondo, S. & Miura, T. Reaction-diffusion model as a framework for understanding biological pattern formation. Science 329, 1616–1620 (2010).

14. 14.

Beekman, M., Sumpter, D. J. T. & Ratnieks, F. L. W. Phase transition between disordered and ordered foraging in Pharaoh’s ants. Proc. Natl Acad. Sci. USA 98, 9703–9706 (2001).

15. 15.

Toffin, E., Di Paolo, D., Campo, A., Detrain, C. & Deneubourg, J.-L. Shape transition during nest digging in ants. Proc. Natl Acad. Sci. USA 106, 18616–18620 (2009).

16. 16.

Mizumoto, N., Kobayashi, K. & Matsuura, K. Emergence of intercolonial variation in termite shelter tube patterns and prediction of its underlying mechanism. R. Soc. Open Sci. 2, 150360 (2015).

17. 17.

Burton, J. L. & Franks, N. R. The foraging ecology of the army ant Eciton rapax: an ergonomic enigma? Ecol. Entomol. 10, 131–141 (1985).

18. 18.

Ben-Jacob, E., Cohen, I. & Gutnick, D. L. Cooperative organization of bacterial colonies: from genotype to morphotype. Annu. Rev. Microbiol. 52, 779–806 (1998).

19. 19.

Dussutour, A., Beekman, M., Nicolis, S. C. & Meyer, B. Noise improves collective decision-making by ants in dynamic environments. Proc. R. Soc. B 276, 4353–4361 (2009).

20. 20.

Pratt, S. C. & Sumpter, D. J. T. A tunable algorithm for collective decision-making. Proc. Natl Acad. Sci. USA 103, 15906–15910 (2006).

21. 21.

Lynch, M. Scaling expectations for the time to establishment of complex adaptations. Proc. Natl Acad. Sci. USA 107, 16577–16582 (2010).

22. 22.

Detrain, C., Deneubourg, J.-L. & Pasteels, J. M. Information Processing in Social Insects. (Birkhauser, Basel, Switzerland, 1999).

23. 23.

Bonabeau, E., Dorigo, M. & Theraulaz, G. Swarm Intelligence: From Natural to Artificial Systems. (Oxford University Press, Oxford, 1999).

24. 24.

Gadau, J., Fewell, J. (eds.). Organization of Insect Societies: From Genome to Sociocomplexity. (Harvard University Press, Cambridge, MA, 2009).

25. 25.

Hölldobler, B. & Wilson, E. O. The Ants. (Harvard University Press, Cambridge, MA, 1990).

26. 26.

Czaczkes, T. J., Grüter, C. & Ratnieks, F. L. W. Trail pheromones: an integrative view of their role in social insect colony organization. Annu. Rev. Entomol. 60, 581–599 (2015).

27. 27.

Dorigo, M., Maniezzo, V. & Colorni, A. Ant system: optimization by a colony of cooperating agents. IEEE Trans. Syst. Man Cybern. Part B 26, 29–41 (1996).

28. 28.

Fujisawa, R., Dobata, S., Kubota, D., Imamura, H. & Matsuno, F. Dependency by concentration of pheromone trail for multiple robots. In Proc. Sixth International Conference on Ant Colony Optimization and Swarm Intelligence, Lecture Notes in Computer Science, (eds. Dorigo, M., et al.) Vol. 5217, 283–290 (Springer Nature, Switzerland, 2008).

29. 29.

Fujisawa, R., Dobata, S., Sugawara, K. & Matsuno, F. Designing pheromone communication in swarm robotics: group foraging behavior mediated by chemical substance. Swarm Intell. 8, 227–246 (2014).

30. 30.

Pfeifer, R., Lungarella, M. & Iida, F. Self-organization, embodiment, and biologically inspired robotics. Science 318, 1088–1093 (2007).

31. 31.

Floreano, D. & Mattiussi, C. Bio-Inspired Artificial Intelligence: Theories, Methods, and Technologies. (MIT Press, Cambridge, MA, 2008).

32. 32.

Mitri, S., Wischmann, S., Floreano, D. & Keller, L. Using robots to understand social behaviour. Biol. Rev. 88, 31–39 (2013).

33. 33.

Doncieux, S., Bredeche, N., Mouret, J. B. & Eiben, A. E. G. Evolutionary robotics: what, why, and where to. Front. Robot. AI 2, 4 (2015).

34. 34.

Bernard, A., André, J. B. & Bredeche, N. To cooperate or not to cooperate: why behavioural mechanisms matter. PLoS Comp. Biol. 12, e1004886 (2016).

35. 35.

Floreano, D., Mitri, S., Magnenat, S. & Keller, L. Evolutionary conditions for the emergence of communication in robots. Curr. Biol. 17, 514–519 (2007).

36. 36.

Montanier, J. M. & Bredeche, N. Evolution of altruism and spatial dispersion: an artificial evolutionary ecology approach. Proc. European Conference on Artificial Life 260–267 (MIT Press, Cambridge, MA, 2013).

37. 37.

Olson, R. S., Hintze, A., Dyer, F. C., Knoester, D. B. & Adami, C. Predator confusion is sufficient to evolve swarming behavior. J. R. Soc. Interface 10, 20130305 (2013).

38. 38.

Tarapore, D., Floreano, D. & Keller, L. Task-dependent influence of genetic architecture and mating frequency on division of labour in social insect societies. Behav. Ecol. Sociobiol. 64, 675–684 (2010).

39. 39.

Waibel, M., Floreano, D. & Keller, L. A quantitative test of Hamilton’s rule for the evolution of altruism. PLoS Biol. 9, e1000615 (2011).

40. 40.

Fujisawa, R., Dobata, S., Sasaki, Y., Takisawa, R. & Matsuno, F. Collision-induced ‘priority rule’ governs efficiency of pheromone-communicating swarm robots. In Proc. Eighth International Conference on Ant Colony Optimization and Swarm Intelligence, Lecture Notes in Computer Sciences (eds. Birattari, M. et al.) 7461, 228–235 (Springer Nature, Switzerland, 2012).

41. 41.

Fourcassié, V., Dussutour, A. & Deneubourg, J.-L. Ant traffic rules. J. Exp. Biol. 213, 2357–2363 (2010).

42. 42.

Iwasa, Y., Michor, F. & Nowak, M. A. Stochastic tunnels in evolutionary dynamics. Genetics 166, 1571–1579 (2004).

43. 43.

Proulx, S. R. The rate of multi-step evolution in Moran and Wright-Fisher populations. Theor. Popul. Biol. 80, 197–207 (2011).

44. 44.

Darwin, C. The Origin of Species by Means of Natural Selection. 6th edn (John Murray, London, 1872).

45. 45.

Mivart, St G. J. On the Genesis of Species (MacMillan, London, 1871).

46. 46.

Bowler, P. J. Evolution: the History of an Idea. 4th edn (University of California Press, Berkeley, CA, 2009).

47. 47.

Suzuki, T. K. On the origin of complex adaptive traits: progress since the Darwin versus Mivart debate. J. Exp. Zool. (Mol. Dev. Evol.) 328B, 304–320 (2017).

48. 48.

Chouard, T. Evolution: revenge of the hopeful monster. Nature 463, 864–867 (2010).

49. 49.

Gould, S. J. & Vrba, E. S. Exaptation: a missing term in the science of form. Paleobiology 8, 4–15 (1982).

50. 50.

Gould, S. J. & Lewontin, R. C. The spandrels of San Marco and the Panglossian paradigm: a critique of the adaptationist programme. Proc. R. Soc. Lond. B 205, 581–598 (1979).

51. 51.

Nowak, M. A. et al. The role of chromosomal instability in tumor initiation. Proc. Natl Acad. Sci. USA 99, 16226–16231 (2002).

52. 52.

Carter, A. J. R. & Wagner, G. P. Evolution of functionally conserved enhancers can be accelerated in large populations: a population-genetic model. Proc. R. Soc. Lond. B 269, 953–960 (2002).

53. 53.

Wagner, G. P. & Altenberg, L. Complex adaptations and the evolution of evolvability. Evolution 50, 967–976 (1996).

54. 54.

Johnson, B. R. & Linksvayer, T. A. Deconstructing the superorganism: social physiology, groundplans, and sociogenomics. Q. Rev. Biol. 85, 57–79 (2010).

55. 55.

Duarte, A., Weissing, F. J., Pen, I. & Keller, L. An evolutionary perspective on self-organized division of labor in social insects. Annu. Rev. Ecol. Evol. Syst. 42, 91–110 (2011).

56. 56.

Paaby, A. B. & Rockman, M. V. Cryptic genetic variation: evolution’s hidden substrate. Nat. Rev. Genet. 15, 247–258 (2014).

57. 57.

Linksvayer, T. A. & Wade, M. J. Genes with social effects are expected to harbor more sequence variation within and between species. Evolution 63, 1685–1696 (2009).

58. 58.

Smith, T., Husbands, P. & O’Shea, M. Neutral networks in an evolutionary robotics search space. In Proc. 2001 Congress on Evolutionary Computation, 136–143 (IEEE, New York, 2001).

59. 59.

Wagner, A. The role of robustness in phenotypic adaptation and innovation. Proc. R. Soc. B 279, 1249–1258 (2012).

60. 60.

Van Nimwegen, E., Crutchfield, J. P. & Mitchell, M. Statistical dynamics of the royal road genetic algorithm. Theor. Comp. Sci. 229, 41–102 (1999).

61. 61.

Schuster, P., Fontana, W., Stadler, P. F. & Hofacker, I. L. From sequences to shapes and back: a case study in RNA secondary structures. Proc. R. Soc. Lond. B 255, 279–284 (1994).

62. 62.

Wyatt, T. D. Pheromones and Animal Behavior: Chemical Signals and Signatures. (Cambridge University Press, Cambridge, United Kingdom, 2014).

63. 63.

Couzin, I. D. & Franks, N. R. Self-organized lane formation and optimized traffic flow in army ants. Proc. R. Soc. Lond. B 270, 139–146 (2002).

64. 64.

Dussutour, A., Deneubourg, J.-L. & Fourcassié, V. Temporal organization of bi-directional traffic in the ant Lasius niger (L.). J. Exp. Biol. 208, 2903–2912 (2005).

65. 65.

Dussutour, A., Beshers, S., Deneubourg, J.-L. & Fourcassié, V. Priority rules govern the organization of traffic on foraging trails under crowding conditions in the leaf-cutting ant Atta colombica. J. Exp. Biol. 212, 499–505 (2009).

66. 66.

Dussutour, A., Fourcassié, V., Helbing, D. & Deneubourg, J.-L. Optimal traffic organization in ants under crowded conditions. Nature 428, 70–73 (2004).

67. 67.

Grüter, C. & Leadbeater, E. Insights from insects about adaptive social information use. Trends Ecol. Evol. 29, 177–184 (2014).

68. 68.

Dorigo, M. et al. Evolving self-organizing behaviors for a swarm-bot. Auton. Robot. 17, 223–245 (2004).

69. 69.

Ferrante, E., Turgut, A. E., Duéñez-Guzmán, E., Dorigo, M. & Wenseleers, T. Evolution of self-organized task specialization in robot swarms. PLoS Comput. Biol. 11, e1004273 (2015).

70. 70.

Pinciroli, C. Trianni, V. & O’Grady, R. ARGoS: a modular, multi-engine simulator for heterogeneous swarm robotics. In Proc. International Conference on Intelligent Robots and Systems (IROS), 2011 IEEE/RSJ, 5027–5034 https://doi.org/10.1109/IROS.2011.6094829 (IEEE, New York, 2011).

## Acknowledgements

We thank H. Shimoji, N. Mizumoto, M.S. Abe, R. Yamaguchi, and T. Tsuchimatsu for discussions. This study was partly supported by Grants-in-Aid for Scientific Research 15K18609 and 17H01249 from the Japan Society for the Promotion of Science (S.D.) and the Hamamatsu Foundation for Science and Technology Promotion (G.I.).

## Author information

R.F. developed simulated and real robot systems; S.D. conceived research; G.I. designed evolutionary analyses; G.I. and S.D. developed programs for mathematical analyses; R.F., G.I. and S.D. performed analyses; S.D. wrote the draft, which was edited by R.F., G.I. and S.D.

Correspondence to Ryusuke Fujisawa or Shigeto Dobata.

## Ethics declarations

### Competing interests

The authors declare no competing interests.

Publisher’s note: Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

## Rights and permissions

Reprints and Permissions