Matan Yah
email: matanbz@gmail.com

Ben Zion

Jeremy Fersula

Nicolas Bredeche

Olivier Dauchot

Morphological computation and decentralized learning in a swarm of sterically interacting robots *

Whereas naturally occurring swarms thrive when crowded, physical interactions in robotic swarms are either avoided or carefully controlled, thus limiting their operational density. Here we present a mechanical design rule that allows robots to act in a collision-dominated environment. We introduce the Morphobots -a robotic swarm platform developed to implement embodied computation through a morpho-functional design. By engineering a 3D-printed exoskeleton we encode a re-orientation response to an external body force (such as gravity) or a surface force (such as a collision). We show that the force-orientation response is generic, and can augment existing swarmrobotic platforms (e.g Kilobots) as well as custom robots even 10 times larger. At the individual level, the exoskeleton improves the motility and stability, and also allows to encode two contrasting dynamical behaviors in response to an external force or a collision (including collision with a wall or a movable obstacle, and on a dynamically tilting plane). This force-orientation response adds a mechanical layer to the robot's sense-act cycle at the swarm level, leveraging steric interactions for collective phototaxis when crowded. Enabling collisions also promotes information flow, facilitating online distributed learning. Each robot runs an embedded algorithm that ultimately optimizes collective performance. We identify an effective parameter that controls the force-orientation response and explore its implications in swarms that transition from dilute to crowded. Experimenting with both physical swarms (of up to 64 robots), and simulated swarms (of up to 8192 agents) show that the effect of morphological-computation increases with growing swarm size.

INTRODUCTION

A robotic swarm is a synergetic ensemble capable of a greater task than its constituents [START_REF] Beni | Robots and biological systems: towards a new bionics?[END_REF]. In a swarm, selforganization is an emergent property, making the swarm resilient to the malfunction of an individual. Swarm engineering poses an interdisciplinary challenge, combining electrical and mechanical engineering, computer science, and non-equilibrium statistical physics [START_REF] Brambilla | [END_REF][START_REF] Hamann | Swarm Robotics: A Formal Approach[END_REF]. Discovering robust design rules for a swarm offers an opportunity to simplify the specifications of the individual robotic units, reducing manufacturing complexity and making production at-scale accessible [START_REF] Brooks | Fast, cheap and out of control[END_REF][START_REF] Dorigo | [END_REF][START_REF] Floreano | From individual robots to robot societies[END_REF][START_REF] Dorigo | Proceedings of the IEEE[END_REF]. Recent development in robotic swarms demonstrated potential applications in collective construction [START_REF] Werfel | [END_REF], coordinated motion for flying UAVs [9][10][11][12], patrol in open water [START_REF] Gomes | International Conference on Parallel Problem Solving from Nature[END_REF] or underwater exploration [START_REF] Zahadat | [END_REF]15]. These applications are characterized by swarms where robots explicitly avoid physical contact [16]. Another approach for swarm design is to keep a cohesive swarm, where robots are constantly touching, keeping a physical interaction that allows continuous transmission of information [START_REF] Saldana | IEEE International Conference on Intelligent Robots and Systems[END_REF][START_REF] Li | [END_REF][19][20][21][22]. This approach showed success in self-assembly and morphogenesis [23][24][25] as well as coordination of a multi-cellular robotic body [26][27][28][29]. To date, artificial swarms are designed to operate exclusively in a dilute, collision-avoided setting, or a cohesive dense population. Resorting to in silico experiments to guide swarm design in a collision-dominated swarm proves limited by the ability to effectively account for the full mechanical interaction. There is a need for physical design rules and robust algorithms where robots maintain a high degree of autonomy in solitude, but also retain functionality in a crowded environment.

Unlike artificial robotic swarms, naturally occurring swarms show excellent flexibility in both dilute and highly dense environments throughout the animal kingdom. At the cellular scale, an individual bacterium can explore space by performing a simple run-andtumble [30], but can also form a dense, highly active bacterial colony that displays internal turbulent flow [31] thereby mixing in nutrients [32,33]. On the millimeter scale, an individual larva can search for food through chemotaxis but self-organize into a living fountain when a large localized food source is present [34]. Macroscopic animals such as fish and birds can individually nest and mate but can come together into giant schools and flocks to evade predation [35,[START_REF] Bbc | Feeding frenzy, from the hunt: Hunger at sea (oceans)[END_REF]. Even pedestrians flow can emerge from simple body collisions [START_REF] Moussaïd | [END_REF]. Swarm cooperation is found on a range of length scales, suggesting that only simple primitive behaviors are required and physical interactions can be used for the swarm's advantage [38]. Interestingly, self-organization in dense assemblies is not a prerogative of living beings. It has been shown that collective motion can emerge from independent mindless robots physically interacting with one another, considering a stripped-down flavor of swarm robotics as a particular kind of active matter with no explicit decision computed at the level of the robots [START_REF]Morpho-functional Machines: The New Species[END_REF][START_REF] Deseigne | [END_REF][41][42][43][44].

Our motivation is to expand the roboticists' toolbox by taking advantage of a generic mechanical response: the tendency to re-orient in response to an external force. We then demonstrate the role of this morphological response in different robotic tasks, both for an individual robot, and a robotic swarm. We introduce two designs to show that this force-orientation response can come in different flavors, aligning with, or against an external force. We show that this force-orientation response can also be used in a robotic swarm platform, giving control over the outcome of a robot-robot collision and the resulting collective behavior.

To achieve this we augment robots with a flexible exoskeleton and show that the morphological difference is encoded in a single effective parameter, labeled κ, that controls the outcome of collisions. We show two different designs that have similar dynamics for free individual robots (i.e a single robot moving on a smooth, flat surface, without experiencing any external force, nor touching any obstacles or robots). But when experiencing an external force, or collision, the two designs have an opposite response. We show that the passive dynamics of the design allow tuning the robot's response to align or oppose an external force. Upon collision, a robot can push against, or slide along an obstacle or another robot, based solely on its mechanical design. The emerging collective dynamics add a morphology layer to a robot's computation, facilitating a combined physical and logical swarm architecture [START_REF] Pfeifer | How the body shapes the way we think: a new view of intelligence[END_REF][START_REF] Pfeifer | Creating brain-like intelligence[END_REF]. We quantitatively analyze the response to an external force and find empirically that it can be described by a single effective parameter, κ. We show experimentally, theoretically, and numerically that a change in the sign of κ inverts the response to an external force, making a robot go down or up a force field. We find κ to be a key design parameter in the response of the robots when encountering an obstacle (be it a wall or another robot). Using positive and negative κ makes two primitives that qualitatively alter the swarm's dynamics in a collision-dominated, crowded environment. We also show that κ can be used to guide the design of collective transport.

We then add a computational layer, where in parallel to the implicit morphological computation, robots execute an explicit sense-act cycle. We experimentally study phototaxis in a partially lit arena, setting a swarm of N = 64 robots to search for the lit region. We set up the illumination field to be unoriented (coming directly from above), and without local light gradients, thus ensuring robots cannot use local information to guide their way to the lit region. Moreover, the lit region is designed to be too small to host the whole swarm. This restriction forces the robots to physically interact, turning the phototaxis task into an exercise of collective aggregation with sterical interactions, going from dilute (in the dark) to crowded (in the light). Studying swarms with positive and negative κ reveals a qualitative and a quantitative different collective phototaxis, directly attributed to the nature of this effective parameter. Finally, we show that the swarm can collectively learn to execute the phototactic task when operating in an environment where individual robots transition between dilute and crowded regions. We implement a decentralized reinforcement learning algorithm inspired by social learning [START_REF] Watson | [END_REF][48][START_REF] Fontbonne | IEEE Congress on Evolutionary Computation (CEC)[END_REF][START_REF] Bredeche | [END_REF], and find that when collisions are allowed the swarm fluidizes, and effectively converges to a successful phototactic strategy despite the sparse and intermittent communication network. We further support our experimental observations with agent-based model simulations, finding that morphology is central to collective behavior and becomes increasingly important with growing swarm size. The interplay of morphology and computation is graphically illustrated in Fig. 1, summarizing the findings of our work.

INDIVIDUAL DYNAMICS The Morphobots

We make Morphobots by augmenting Kilobots [23] with a 3D-printed exoskeleton. The Kilobot is a 3.4 cm tall, 3.3 cm diameter unit, standing on 3 rigid legs made of thin metallic rods. The Kilobots are capable of differential drive locomotion using two vibrators. When either is activated, a Kilobot turns at about 45 deg per second, and when both are activated, the Kilobot moves forward. The power source is a rechargeable lithiumion battery that can keep the Kilobot running for a few hours. Kilobots are equipped with an infrared transmitter and receiver so that they can communicate with each other. The transmitter of a robot sends light toward the surface which reflects up to the receiver of another nearby robot. Obtaining straight motion over long distances is difficult and requires lengthy calibration of the individual vibrators [51], moreover, the calibration itself drifts over time.

To both improve the robot's nominal speed, and eliminate the need for individual calibration, we encapsulate the Kilobots within exoskeletons that change how collision and locomotion are performed. We made two tripodbased designs (a pair of flexible legs and an opposing stiff leg), with both designs having a circular chassis (diameter d = 4.8cm). The two designs, which we shall call fronter versus aligner, differ in the fore-versus-aft positioning of their flexible legs (see Fig. 2-A,B,C and Methods). The natural vibration of the semi-flexible legs is tuned near resonance with the vibration motors, to maximize the coupling with their drive. Using an anisotropic flexible leg design (1mm thick, 6 mm wide, and 20 mm long, see Supplementary Materials), vibrations are coupled predominately to the forward stick-slip motion of the robots. The exoskeleton does not interfere with the ability of the robots to communicate, and has multiple roles including energy storage of vibrations, near-resonance coupling to motors, anisotropic design to translate motor-vibrations into a forward motion. The exoskeleton allows a Morphobot to operate at an order of magnitude higher speed than the Kilobots (see Fig. 2-D and Supporting Movie 1). More importantly, it allows control of the response to external forces and collisions.

By tracking the motion of individual Morphobots, we find that aligners and fronters show near-identical motility. Motility is defined by the magnitude of the displacement of an individual robot over different timescales, and measured by tracking the time evolution of their twodimensional coordinates, r (t) = (x (t) , y (t)), when run-ning in the experimental arena [52]. Only a low concentration of robots was used (less than 1% filling fraction) excluding the effect of collisions, and robots were tracked only when away from the walls of the arena. The mean square displacement, MSD = ∆r 2 (∆t) N , of an ensemble of noisy walkers, presents two dynamical regimes [53]. On short time intervals ∆t, the displacement of the robots is aligned with the direction of their individual orientation and displacements are proportional to ∆t. The motion is said to be ballistic when robots go roughly on a straight line at a constant speed: ∆r 2 (∆t) N = v 2 0 ∆t 2 , where v 0 is the instantaneous speed.

On long time intervals, the noise has reoriented the robots several times and displacement grows as √ ∆t as robots explore the space randomly. The motion is now said to be diffusive ∆r 2 (∆t) N = 4D 0 ∆t, where D 0 is called the diffusion constant. The noisy trajectories of the robots originate from the stochastic nature of their vibrational drive [54], as well as the roughness of the arena and internal electronic drift. The two regimes (∝ ∆t and ∝ √ ∆t) are separated by a crossover, which takes place on a time scale called the persistence time, τ p (see below), to which corresponds a persistence length ∆r 2 (τ p ) 1/2 N . Fig. 2-D displays the mean square displacement measured for a set of Morphobots equipped with the two types of the exoskeleton, together with their ensemble average (the MSD of 8 robots of each design were measured, shown as separate curves in Fig. 2D, see also Table I ). One sees that the difference in motility between the two designs is no larger than the robot-to-robot variation within each design. The observed ballistic nature of the mean square displacement (∝ v 2 0 ∆t 2 ) indicates that the persistence length of the motion is larger than the size of the circular arena (diameter D = 150 cm). Fitting the ensemble mean square displacement in the ballistic regime, we find that the mean nominal speeds are 5.2 ± 0.9 cm/s and 4.8 ± 0.1 cm/s for the aligners and fronters respectively. The measured effective parameters are summarized in Table I.

Altogether, the anisotropic leg design allows us to use higher motor drive while keeping the robot's trajectories straight, alleviating the need for individual robot calibration, and resulting in a nominal speed of v 0 5 cm/s, a ten-fold increase, relative to the bare Kilobot design (see Supporting Movie 1). The notion of using passivedynamic machines [55] allowed to achieve a similar feat in bristle bots, using rows of soft legs [56], and in the commercially available HEXBUG [28,29,57,58]. Using the differential drive, robots can also pivot at 45 deg per second. Programming alternated straight and pivoting motion of random duration and random direction, we can set the Morphobots into a run-and-tumble motion [59], where, on average, the robots run straight during a run time τ run = 2 s, with a velocity to be specified, and tumble during a mean tumble duration τ tumble = 4 to the orientation vector n. D mean square displacement versus time shows the ballistic response for both designs (∝ t 2 ), with a typical speed of 5.2 cm/s (4.8 cm/s) for the aligners (fronters). Also shown, the mean square displacement of a bare Kilobot which after calibration can also move ballistically, but at a speed one order of magnitude slower (0.53 cm/s). Inset: 12-second long trajectories of fronters (green) and aligners (cyan), and a 36-second long trajectory of bare Kilobots (gray) inside the 150 cm diameter arena.

s. The total duration of a run-and-tumble sequence sets τ RT = τ run + τ tumble , with the resulting persistent time being τ P ≈ 18 s (See SM).

Fronters vs. Aligners response to an external force

We systematically measure the response of the two Morphobots designs to an external body force by placing the robots on a plane tilted by a small angle, ϕ. The two designs have a polar different response: aligners go downhill, while fronters climb against gravity (Fig. 3A,B and Supporting Movies 1-6). The effect is consistent, regardless of the initial orientation of the robot being along the positive y direction (downhill to its right), or negative y direction (downhill to its left), excluding the effect of an internal left/right bias (see . We systematically increase the slope (see Fig. 3C), and find that with increasing ϕ, the trajectories turn increasingly curved, until the robot orients downhill (aligner) or uphill (fronter).

To quantify the different responses of the robots to an external body force, we modify a model introduced in the context of active matter to describe self-aligning particles [57]. A Morphobot has two translational r = (x, y) and one orientational n = (cos(θ), sin(θ)) degree of freedom. In the overdamped limit, the deterministic dynamics of the velocity v and orientation n of a Morphobot with a nominal speed v 0 subjected to a body force f (see Fig. 3D) obey the following equations :

d r dt = v = v 0 n + µ f (1)
dn dt = κ (n × v) × n, ( 2
)
where µ is the particle mobility and κ is the alignment parameter -an effective parameter describing the reorientation by force. The first equation simply states that the velocity is the additive combination of the propulsion velocity v 0 n and the speed induced by the external force, µ f . The second equation contains the key ingredient of the model. It describes the reorientation of the Morphobot along the direction of its motion. The coupling between an external force and the orientation is captured through an effective alignment parameter, κ. This parameter measures to what extent an external force, f , affects the orientation of a robot, n. In the most simple case, κ = 0, and an external force does not affect the orientation of a robot (Eq. 2 becomes redundant). However, generically force and orientation do couple, and κ is finite (κ = 0). Moreover, κ is signed as it can be positive or negative. This means that when subjected to an external force the robot does not only translate, but it also rotates. The larger the magnitude of the alignment parameter, κ , the quicker a robot's orientation will respond to an external force. There are two important types: when positive (κ > 0) a robot aligns parallel with an external force. Here we call robots with positive κ aligners. When negative (κ < 0) a robot aligns antiparallel to an external force. Here we call robots with and fronters (green) moving on different slopes (ϕ). Aligners and fronters have an opposite response to the external forcealigners' orientation turns downwards as they quickly descend, while fronters turn upwards, and slowly ascend. D Throughout its motion, the orientation of the robot, n, forms an angle θ with the external force, f , together setting the net velocity v (see Eq. 1). E Tracking the orientations shows that aligners turn downhill (θ → 0), aligning with the external force, while fronters turn uphill (θ → π), fronting the external force (see also . Solid curves are fits to Eq. 4, from which κ can be extracted (see SM). F Average fitted κ for each incline angle and robot-design (error bars are the standard error). For finite tilt angle, the response of the two designs is approximately equal and opposite κ aligner = -κ f ronter ≈ 0.3/d. At a slope near zero, the response is dominated by the robot's internal bias (left/right curving and internal noise [54]), but averages to zero. Scale bar is 20 cm. negative κ fronters. κ is an effective parameter and results from the design details of the robot (material properties, mass distribution, drive mechanism, and so on). And yet κ is empirically well defined as it can be experimentally measured and quantitatively compared between different robotic platforms. For a constant force in the x direction f = f x, with f = mgsinφ, where m is the mass of the Morphobot and g is the acceleration of gravity, the dynamical evolution of the orientation, θ = θ (t) relative to the x axis obeys a closed form equation :

dθ dt = -κµf sinθ. ( 3
)
Eq. 3 is the equation for an overdamped simple pendulum, which can be solved directly to give tan θ 2 = e -κµf t (for initial condition θ (t = 0) = 90 o ). In the limit where v 0 µf , when the orientation is expressed as a function of the arclength, θ (s), it is found to be independent of the external force and mobility (see Supplementary Materials),

θ (s) = 2atan e -κs . (4)
To find the alignment parameter, κ, we tracked the ori-entation of individual robots as they move across a fixed inclined plane (see Fig. 3E, Movies 3, 4, and Methods).

In the absence of an external force (zero slope, φ = 0 • ), both fronters and aligners move on roughly straight lines.

For steeper inclines (φ = 3 • and φ = 6 • ), both designs show a similar rate for the convergence of the orientation. Fitting the evolution of the orientation to Eq. 4, we extract the alignment parameter, κ. The magnitude of κ for both designs is similar, but with opposite signs:

-κ f ronter ≈ κ aligner ≈ 0.06 cm -1 . The measured effective parameters are summarized in Table I. We find that the design rules controlling the alignment parameter apply also in a dynamically changing environment as well as to robotic platforms of different sizes (see Fig. 4). Placing a Morphobot of either type on a seesaw gives rise to a unique behavior (Fig. 4): An aligner turns quickly downhill and falls off the seesaw, while a fronter turns upwards and climbs. Once passing the center of the seesaw, the mass of the robot suffices to tip the plane of the swinging table. The fronter is now facing downhill, yet, again, as it moves, it turns around and recommences climbing, until passing the center of the seesaw once more, where these dynamics repeat, effec- tively tracing loops (see Fig. 4B and supporting Movie 2). Moreover, the design rules for the Morphobot generalizes to a custom robotic platform independent of the Kilobots (Fig. 4D) and can be made 10 times larger (see Movies 5 and 6).

f v0 (d/s) κ (1/d) Aligners 1.1 ± 17% 0.3 ± 10% Fronters 1.0 ± 2% -0.3 ± 20%

Interaction with a wall

Using the response of the Morphobots to an external force we can predict their steric interaction with stationary walls, movable objects, and with one another. Morphological interaction with a boundary (stationary or movable) can be seen as a series of collisions, at each of which the robot experiences an external force (see Fig. 5-A). With each collision, a Morphobot slightly reorients. An aligner orientation approaches the normal force from the wall (but leaves when parallel to the wall). A fronter turns against the normal force (and towards the wall). This is confirmed by the direct observation of Morphobots sent to move towards a wall of stationary robots (see Fig. 5-B). Arranging turned off robots into three, tight rows forms effective wall with which a moving robot mechanically interacts. On average, both designs spend similar time near the wall (∼ 3τ p ≈ 1 min) but aligners travel a path along the wall which is twice longer than that of the fronters (see Fig. 5-C and Movie 1). Using a multi-agent Brownian dynamics simulation of active soft discs, we were able to predict the outcome of collisions based on the alignment strength parameter κ. During a collision, an agent with κ > 0 (aligner), turns towards the normal force, and away from the obstacle, whereas an agent with κ < 0 (fronter) turns against the normal force and into the obstacle thus pushing it. Also, simulating agents with κ < 0 near a passive particle shows that the agents collectively move the passive object (see Fig. 5-D). This has been confirmed experimentally by using a group of fronters that work together to push a circular object (see Fig. 5-E and Supporting Movie 1). Previous work showed that collective transport can be implemented using global control [START_REF] Shahrokhi | IEEE International Conference on Automation Science and Engineering[END_REF]. Here we extend this notion and show that a single, effective alignment parameter, κ, captures embodied dynamics of sterically interacting agents, reducing the required computing resources for simulating a large swarm in a crowded environment.

COLLECTIVE DYNAMICS

We turn to study the ability of a swarm of Morphobots to execute a collective task, focusing on phototaxis, where robots explicitly use their sensory and computational power in addition to the morphological interaction. Phototaxis is a common behavioral trait found in nature where an organism changes its motion in response to locally measured light. Phototaxis pervades the animal kingdom, from individual bacterium to groups of vertebrates. Phototaxis is classified as either positive, where the organism seeks to be present in the light (such as moths [START_REF] Lees | Moths: A Complete Guide to Biology and Behavior[END_REF]) or negative, where the organism prefers the dark (such as golden shiners [START_REF] Berdahl | [END_REF]). Here we test the ability of a robotic swarm to perform this widespread natural behavior, with an emphasis on the collective abil- Tuning interaction with a static and a moving obstacle using morphological computation. The morphological interaction of the Morphobots with walls can be explained using their response to an external force. When a Morphobot collides with a wall, each impingement can be seen as a momentary normal force. A Aligners turn to align their orientation (black arrow) with the normal force (red). Once aligned along the wall, there is no further rotation as there are no more collisions, and the robot slides along. B When a fronter collides with a wall, its orientation (black) turns anti-parallel with the normal force (red), and the robot continues to push into the wall. When programmed to run-and-tumble, aligners and fronters interact differently with a wall of stationary robots where aligners (A) cover a much larger distance along the wall relative to fronters (B). C Multiple collision experiments show that aligners and fronters spend similar time near a wall (3τp ≈ 1 min) yet aligners move twice as fast. D Brownian dynamics simulations predict that active particles with a negative alignment parameter, κ < 0 (fronters), push a movable object. E With real robots: placing a round movable obstacle shows that a swarm of fronters is capable of transporting an object. Scale bar is 10 cm.

ity to maximize the time spent in the light (positive phototaxis). We program the robots to change their speed in response to the locally measured light intensity (also known as photokinesis [63]) and show that the robots' morphology can be used to improve their collective phototaxis when crowded. Stimulus-induced locomotory movements (or taxis) constitute an important building block in swarm robotics [START_REF] Brambilla | [END_REF][START_REF] Hamann | Swarm Robotics: A Formal Approach[END_REF]19,[START_REF] ¸ahin | International workshop on swarm robotics[END_REF][START_REF] Bayindir | [END_REF][66], and several bio-inspired algorithmic implementations have been proposed for phototaxis using ambient light sensors [26,[START_REF] Hamann | IEEE/RSJ International Conference on Intelligent Robots and Systems[END_REF][START_REF] Schmickl | [END_REF][69][70].

Collective phototaxis in the presence of steric interactions

The experimental setup for collective phototaxis was designed to prevent an individual robot from accessing global information that could guide its sense-act cycle. For this, we set a swarm (N = 64 bots) of either aligner (κ > 0) or fronter (κ < 0) to explore a circular arena (diameter D = 150 cm) with a lit spot that covers only σ = 6% of the area of the arena (diameter b = 36 cm, see Fig. 6-A and Section in SM). The light is unoriented (coming from above), and there are no local light intensity gradients to guide a robot to the lit region (the light field is essentially flat). This excludes the use of traditional phototactic algorithms such as steepest descent search [25,[START_REF] Schmickl | Bio-inspired computing and communication networks[END_REF] or reorientation [23]. The lit region can not accommodate more than 80% of the robots (about 50 Morphobots), challenging the swarm to transition between sparse and crowded.

As a first step, we consider ad hoc calibrated swarms, where the Morphobots' policies are defined as follows. Each Morphobot continuously monitors local light intensity: when in the dark (below a predefined intensity threshold, P th ) the robot performs a run-and-tumble motion, with a running velocity V 0 . When entering a bright region (light intensity above P th ), the robot stops, V 1 = 0. At early times, when there are only a few robots in the lit region, the two designs show similar performance as measured by the fraction of the swarm that is in the light

F ≡ N 1 N , (5)
where N 1 is the number of bots taxied in the light. At the beginning of every experiment, robots are placed in the arena with random positions and orientations. At early times, F is quantitatively captured as a diffusionlimited process (see Fig. 6-F), with the kinetic reaction constant found using Smoluchowski first passage computation for diffusive particles with an effective diffusion constant, D ef f ≈ 4.2 2 cm/s (See Supplementary Materials) [START_REF] Smoluchowski | [END_REF]. After approximately 10 minutes, both swarms deposit the first layer of robots at the perimeter of the lit region (Fig. 6B,D). From this point onward, the phototaxis rate slows down and deviates from the simple diffusion-limited reaction, as crowding of taxiing robots at the perimeter of the light spot physically prevents further robots from entering the lit region (Fig. 6C,E). This steric effect is quantitatively more pronounced for the aligner design, as can be seen for the overall performance given by the fraction of the swarm that has entered the lit region over long times (Fig. 6F). The reason is that the collective success of each swarm depends on the morphological interactions of a robot impinging from the dark region on the first layer of robots at the perimeter of the lit region. Individual Morphobots arriving at the wall of stationary robots show qualitatively different dynamics for either design: an aligner (κ > 0) that arrives at the wall tends to reorient along the wall until it finally leaves, whilst a fronter Morphobot (κ < 0) tends to "dig in", pushing already taxied robots into the lit region until taxied itself (see Fig. 6B,D). These individual events add up: fronting Morphobots progressively push the perimeter inwards, constantly filling the bulk of the lit region with robots. By contrast, the aligning Morphobots keep reorienting away from the robots at the perimeter, leaving a hollow in the lit region (see Fig. 6 C, E and Supporting Movie 1). This discrepancy exacerbates as the swarm size increases. By simulating up to 8192 phototactic agents that follow Eqs. 1,2 we find that a swarm of aligners (κ > 0), becomes considerably slower to phototaxis relative to an equivalent swarm of fronters (κ < 0). The typical time, T 1/2 , to have half of the swarm in the light (F = 1/2) grows much faster for aligners than for fronters (see Fig. 6G,H). The above findings demonstrate that the collective ability of the swarm to perform a phototactic task at scale hinges on a subtle morphofunctional difference.

Distributed learning of a phototactic strategy

The swarms considered thus far had the environmental information hard-coded into individual robots before deployment -the sense-act cycle of every robot had a pre-programmed, ad-hoc knowledge of the correct light threshold for phototaxis (which is an unrealistic assumptions when robots are to be deployed in an unknown environment). Concurrent challenges however require deployment of robotic systems in unknown terrains [START_REF] Brambilla | [END_REF][START_REF] Hamann | Swarm Robotics: A Formal Approach[END_REF][START_REF] ¸ahin | International workshop on swarm robotics[END_REF][START_REF] Bayindir | [END_REF], including extra-terrestrial exploration, underwater surveying, and search-and-rescue missions [73][74][75]. Under such circumstances, robots will lack an a priori model of the environment that can be pre-programmed. This requires an added layer to the robots' controller for online tuning of the sense-act cycle based on continually acquired knowledge. In such conditions, a distributed robotic system offers robustness with scale, improving both exploration and survival. A distributed system however also poses a challenge as the swarm has to learn collectively.

In this final section we test whether a swarm can collectively learn even when robots collide. We show that in a swarm of Morphobots, both execution and learning can be made fully distributed (see Fig. 7). We then proceed to test the effect of the two designs on the collective performance and find numerically that over long enough time, a swarm of fronters out-performs a swarm of aligners. Since the robots are allowed to collide, the swarm is fluidized [76]. An individual collision event may be stochastic, but the mean data flow within the swarm becomes predictable. Unlike a solid or a jammed state (where individuals do not move), here the swarm acts as a fluid, meaning that it satisfies good mixing, as robots frequently exchange neighbors and visit various parts of the arena, sustaining a flow of information (see Figs. S4, S5 in supporting information). Each robot evaluates its performance and compares it to other encountered robots. The selection algorithm can be made distributed by implementing a decentralized online reinforcement learning scheme, to make the swarm adaptive.

Previous work showed that a swarm can learn a phototactic strategy with a policy defined by the weights of an Artificial Neural Network as a controller, π = {w i } [START_REF] Trianni | European Conference on Artificial Life[END_REF][START_REF] Dorigo | [END_REF][79]. There, the learning was implemented using an evolutionary algorithm to act as a direct policy search, using a reinforcement learning method, incrementally refining behavioral policies by directly tuning the policies' parameters [START_REF] Nolfi | Evolutionary Robotics: the Biology, Intelligence, and Technology[END_REF][START_REF] Doncieux | [END_REF]. The swarm is randomly initialized with a pool of sense-act policies, and in an iterative selection process, only the best-performing policies are carried over to the next generation. In these algorithms, the execution is indeed distributed over the swarm, but it is a central computer performing selection and optimization (see Fig. 7D). Such schemes are impossible to implement outside the lab if the swarm has no access to an external operator for guidance, nor a global communication channel to compare performances. In what follows we show that despite having a sparse and intermittent network, communication in a swarm of Morphobots becomes effectively connected across time thanks to the swarm's fluidity, facilitating decentralized learning (see Fig. 7F).

For a successful reinforcement learning algorithm to converge, a suitable reward function, ρ, must be defined [82]. As an input, the reward function receives the robot's sensory information ρ = ρ ({i i }) and out-puts a scalar score (see Fig. 7A and Algorithm 1 in SM). The combination of an individual robot sense-act policy, π = π ({w i }), and the environment it sampled, results in a robot's reward at a given time. Robots can also communicate when within communication range and exchange their policies and rewards (Fig. 7 C, F1-F4). Following such an exchange, a robot can choose to adopt the received policy based on its associated reward, operating under the assumption that a higher reward is the result of a superior policy. Unlike classical evolutionary algorithms that use a centralized computer to compare performance, the scheme presented here allows embedding both the evaluation and the selection within the robot. In other words, robots collectively perform a kind of social learning, where successful individual innovations diffuse over the population [START_REF] Watson | [END_REF]48,[START_REF] Bredeche | [END_REF]. Note that the assumption that a higher reward is a result of a superior policy may not be always true. From time to time robots with an incidental favorable history can have a disproportional higher reward. Such bots will propagate a poor policy globally to the swarm, effectively spreading 'fake news'. This local-to-global gap challenges the chosen reward function to be robust to such fluctuations. The fluid nature of the swarm of Morphobots allows us to choose ρ that overcomes this culprit. Most swarm robotic systems employ a collision avoidance algorithm that slows down their collective dynamics, jamming the information flow, and creating deadlocks [START_REF] Werfel | [END_REF]. By contrast, the Morphobots are allowed to collide, sustaining good mixing, and offering a quantitative link between global and local information (see Figs. S4, S5 in Supplementary Materials).

To formulate a proper reward function we note that the collective phototaxis, F, as defined in Eq. 5 is an ensemble average, N , counting the fraction of the swarm that is in the light at a given time. F can not be directly optimized by an individual robot as it stores global information. However in a system with good mixing, a time average can approximate an ensemble average φ ≡ T ≈ N . A time average equivalent to the ensemble average given in Eq. 5 is the mean time an individual robot spent in the light, Φ ≡ T in light /T ≈ F. In a distributed robotic system with good mixing, a reward function that estimates the mean time the robot spent in the light can serve as a proxy for the global performance of a swarm of its kind, ρ ∝ Φ ≈ F. Robot i can evaluate the mean time it spent in the light through a temporal average of its light sensor signal:

ρ i = 1 M M -1 k=0 P i k , (6)
where M is the number of averaged measurements, and P i k is the the k'th measurement taken at constant time intervals. Since the time a robot spends in the light is inversely proportional to its speed in the light, Φ ∝ ρ ∝ 1/V 1 the above choice of reward function is analytically linked to a given policy. This link allows us to show that when formulated as a dynamical process, collective learning will indeed converge on average (see SM for detailed derivation).

To test the validity of the proposed decentralized learning scheme, we deployed a swarm of Morphobots in the same light-patterned arena, but this time with randomly initialized policies (See Fig. 7, Supporting Movie 1). A "correct" policy corresponds to a set of weights {w i } of the perception, where the robot slows down in the light. A "wrong" policy corresponds to a set of weights, where the robot does not slow down in the light. When randomly distributed in the large arena used (150 cm), robots are on average over 16 cm apart (see for example 01:41 in Movie 1). This is more than twice the maximum communication distance supported by the Kilobot platform (7 cm). At such a separation, many of the robots are out of communication range from one another making the network sparse. Not only the network is sparse, but the network is also intermittent. Even when two robots do come within communication range, they quickly move away. On average, the subgroup of the swarm that interacts at a given time makes up only a small fraction of the swarm, and this subgroup is constantly changing. Altogether making a sparse and intermittent communication network. We also program the robots to start with random initial policies by drawing their weights at equal probability from values ranging between 0-255 (see Methods Section and Supplementary Materials for details). At very early times only a few robots slow down in the light -most robots either stand in the dark or move quickly through the lit region. And yet the swarm fraction in the light progressively increases with time. We tested swarms of both aligners and fronters, and found a consistent increase in the fraction of the swarm in the light reaching approximately F ≈ 0.4. At these swarm fractions in the light, the difference between fronters and aligners is not expected to be significant as is evident here (compare with Fig. 6F at early times). The learning swarms had 8 times more robots in the light than the case of random placement that is, the fraction of the lit region, σ = 0.06. Given that Kilobots are ten times slower, and diffusion scales as the speed square (∝ v 2 0 , see SI), a swarm of bare Kilobots would have taken 100 times longer to converge, making collective learning impossible. The fact that the adaptive swarm performed almost, but not quite as well as, the pre-calibrated swarm is not surprising and may be attributed to the fact that dynamics of about half of the randomly initialized population are very slow (as they stand in the dark), and given enough time, they will also eventually learn. This may be resolved by expanding the learning space of the sense-act cycle, to have the robots also learn the speed in the light, V 1 .

We find that the difference between learning swarms of aligners and fronters increases with time. By extending the multi-agent numerical engine, we tested the learning process over a longer duration (inaccessible experimentally) and for larger swarms (up to 8 times larger, see Fig. 7H and Fig. S3 in supporting information). Implementing Algorithm 1 numerically, we find that after approximately τ ≈ 300 -400 from their initialization, swarms of either aligners or fronters reach the same fraction of robots in the light (F ≈ 0.4, Fig. 7G), consistent with Morphobots studied in the laboratory. In both experiments and simulations, we find that at these intermediate times, the swarm of fronters tends to occupy the lit region while aligners remain on the perimeter (see Fig. 7G,H). Simulations show that at later times (τ > 400) this qualitative difference grows: the fraction of aligners in the light remains the same, whereas the swarm of fronters continues to crowd the lit region, reaching F ≈ 0.55. This effect is consistent with growing swarm size, showing the significance of morphological interaction at scale in adaptive swarms.

CONCLUSION

In this research article, we introduced a robotic swarm that can operate in both dilute and dense settings, where collisions between robots occur frequently. We show that the robots' physical morphology plays an important role in terms of collective behaviors, where a seemingly small change in the shape leads to very different outcomes. Applying tools from statistical physics of active-matter to swarm robotics, we show that behavior found in natural swarms (such as ant colonies [83]) including collective self-aggregation and transport can be attained with limited use of software-controlled behaviors, by capitalizing on the morphological properties of robots, demonstrating morphological computation at work within the swarm.

We also showed that distributed online evolutionary reinforcement learning can be implemented in a dense robot swarm, to exploit or mitigate physical contingencies after deployment in the open. We find that this kind of artificial social learning, when robots locally exchange information about their behavioral strategies, can be modeled as a conditional diffusion process.

Future collective learning implementations in swarm robotics can go beyond the diffusion of behavioral strategies. An extreme case is of sparse swarms, where individual robots or groups may be temporarily disconnected from the whole [84]. While dense and sparse robot swarms may be considered separately, a robot swarm in the open will likely have to switch from one configuration to another, requiring versatile social learning capabilities. A natural extension can be motivated by cultural evolution found in nature [85], which is built on the reformulation and combining previously learned behaviors to continuously discover behaviors of growing complexity.

Future physical models of a learning swarm should go beyond the mean-field approximation used here and account for the spatial density fluctuations (as is done for describing the motility-induced phase separation observed in active fluids [59,86]). From that point of view, our work shows that building upon the recent theoretical progress made in describing the population of active particles, one can envision a rapid development of a statistical mechanics description of smart active matter, for future swarm engineering.

MATERIALS AND METHODS

Exoskeleton design and manufacturing

Exoskeleton Manufacturing

Exoskeletons were 3D printed using either one of the following 3D printers and materials to give similar results: startAsys Objet350 Connex3 printer, using vero-Clear (modulus of elasticity E = 1 -2 GP a, density ρ = 1.2 g/cm 3 ), 3D systems projet 2500plus printer using VisiJet M2R-CL (MJP) (density ρ = 1.14 g/cm 3 , Elastic modulus E ≈ 1 GP a), Prusa i3 printer using PLA (density ρ = 1.2 g/cm 3 , elastic modulues E = 5 GP a).

Data acquisition and experimental setups

Phototaxis experiments

Phototaxis experiments were performed on a 5 mm translucent plexiglass sheet placed on the floor (PMMA 27000 Diffusant Laiteux 40%, WEBER METAUX). A circular region 6% of the arena was lit using a projector (EPSON EB-1795F), at RGB = (10,255,255), at approximately the spectral sensitivity peak (570 nm) of the Kilobot's light sensor (TEPT5700, Vishay Semiconductors). To reduce interference of ambient light with the light sensor, the arena was lit using four desk lamps directed at the surrounding walls (for a homogeneous diffusive illumination) and covered with red cellophane (where the robot's light sensor's sensitivity is at a minimum). Red cellophane also covered the camera used for acquisition (PIXELINK.PL-D734MU), to reduce the saturation from the lit region, and imaging of the robots. Image acquisition was carried out using µicromanager [START_REF] Edelstein | [END_REF], at 2 frames per second. Robots are counted when fully in the light and results shown in Figs. 6F, 7G are the average of four realizations with error bars being the standard deviation.

Code used

Robots were programmed to phototaxis using variations of the following two codes: 1. phototaxisAdhoc.c -robots stand when their photoperceptron is activated given a predefined threshold. 2. phototaxisLearning.c -Robot stand when photoperceptron is activated but light threshold are randomly initialized and evolve through the learning algorithm.

Inclined plane experiments

Coupling between external force and robot's orientation was measured by letting robots run on a plane made of 5 mm thick plexiglass placed at an incline, and imaged using SonyAlphaS7 camera, with video-rate image acquisition at 30 frames per second. See supporting Movies 3-6.

Data analysis

Raw images were preprocess using ImageJ [89], or FFmpeg, followed by particle locating using trackpy package [52], or custom code, and trajectories were linked using trackpy [52].

Simulating Morphobots

Computer simulations were carried out by adding a stochastic term to the Eqs. 1, 2 and using 5th order Runge-Kutta for the time propagation of Brownian dynamics of active soft-discs by adopting code from previous publications [90][91][92].

Custom Morphobots

Design files and bill of materials for custom Morphobots (Fig. 4 in the main text) are found in the extended data. At their core, custom Morphobots are made from a 3D-printed flat chassis onto which a battery (LIR 2477), an electric switch, and two vibration motors (Best-Tong 14kRPM 3 Volts) are mounted. The chassis has two holes for mounting flexible curved legs (which can be 3D printed separately).

Morphological computation and decentralized learning in a swarm of sterically interacting robots -Supplementary Materials * Matan Yah Ben Zion 1,2,3 , † Jeremy Fersula 1,2 , Nicolas Bredeche 2 , and Olivier Dauchot Exoskeletons were designed as a round chassis (diameter d = 4.8 cm) with an off-center cavity where the Kilobot is pressed in. The exoskeleton stands on three, L = 2 cm tall legs -one leg is stiff and round, and two opposing legs that are flexible and with a rectangular cross-section (thickness T = 1 mm, and width W = 0.6 cm, see Fig. 2 in the main text as well as previous work on elastic beams [93,[START_REF] Zhu | Proceedings of the National Academy of Sciences[END_REF]). The flexible legs were designed to have their first natural vibration near resonance with the vibration motors frequency (Pololu 10X2.0 mm vibration motors, f motor ≈ 250 Hz). This was done by estimating the legs to be elastic beams which are described dynamically using the Euler-Bernoulli beam theory for a homogeneous thin beam

EI ∂ 4 h ∂x 4 = -µ ∂ 2 h ∂t 2 , ( 7
)
where h is the deflection, E is the elastic modulus, µ is the linear mass density (given by µ = T W ρ), and I is the beam moment of inertia (given by I = W ×T 3 12 ). In Fourier space, Eq. 7 becomes

ω = EI µ k 2 , ( 8
)
where ω is the angular frequency, and k the wave number. The wavelength of the first harmonic λ 1 of a beam of length L fixed at one end is λ 1 = 4L, along with Eq. 8 allows us to find that the natural first harmonic of the leg is to leading order

f 1 = π 16 √ 6 E ρ T L 2 . (9)
Note that Eq. 9 is independent of the width. Given the materials and geometry used (see the previous section), f 1 ≈ 250 Hz ≈ f motor .

Individual robot dynamics

Speed of an individual persistent particle

The effective diffusion constant of a run-and-tumble particle, that covers a distance l p , during the time inter- [START_REF] Howse | [END_REF]. In the run and tumble mode, each Morphobot is programmed to run for τ run = 2 s at its nominal speed of v 0 ≈ 5 cm/s, then perform a tumble where it pivots on average for τ pivot = 4 s. The step size is thus l p = v • τ run ≈ 10 cm, and the total duration is τ RT = 6 s. The resulting effective diffusion constant is D ef f ≈ 1 4 (10 cm) 2 /6 s = 4 cm 2 /s.

val τ RT is D ef f ≈ 1 4 l 2 p /τ RT

Particle orientation as a function of trajectory length under constant force

The dynamics of the orientation, θ, relative to the positive x direction, for an active particle in the over-damped limit in the absence of noise is found to be that of a simple overdamped pendulum (Eq. 3 in the main text) [96]:

θ = -κµf sinθ. ( 10
)
It is helpful to formulate Eq. 10 as a function of s, the trajectory traveled. In 2D, s is defined locally by the Euclidean distance:

ds 2 = dx 2 + dy 2 . (11)
Dividing Eq. 11 by dt 2 reminds us that

ds dt 2 = dx dt 2 + dy dt 2 = v 2 (12)
We can find v 2 by multiplying Eq. 1 (main text) by itself:

v 2 = v 2 0 + (µf ) 2 + v 0 µf cosθ. ( 13
)
Using the chain rule, dθ dt = dθ ds ds dt , and plugging into Eqs. 12 and 13, we get an ODE describing θ as a function of s, the arclength:

dθ ds = κf cosθ v 2 0 + f 2 + v 0 f cosθ . ( 14
)
Equation 14 can be solved exactly, however, it is more instructive to examine the limit of v0

Photoperceptron

Each robot has a photoperceptron encoded to measure environmental cues, and take a specific action given whether the perceptron fired or not. The minimal architecture for the photoperceptron implemented has a neural network of a single neuron (perceptron), with two inputs, bias b = x 0 , and the locally measure light power p = x 1 , and their associated weights w 0 and w 1 , which together effectively define the threshold for firing. The perceptron output is p, a logistic function of the form

p = 1 1 + e -h . (17)
where h = 1 i=0 w i x i

Sense-act cycle

The sense-act cycle uses the robot's local light intensity measurement, where the robot chooses between two meta-behaviors: run and tumble or walk and tumble, given the photoperceptron is below threshold P < 0.5, or above threshold P ≥ 0.5, respectively. In both cases, the motion is a sequence of a moving phase (run/walk) and a tumble phase. In the tumble phase, the robot randomly chooses a direction (clockwise or counterclockwise) and a random duration with a mean of 6 seconds. Randomizing the duration compensates for the robots' internal dynamical variability and environmental variability. For example, robots with stronger/weaker motors will take less/more time to tumble and complete the same reorientation. Similarly, a robot near a wall (or another robot) or in solitude. When in run mode, the robot sets both motor values to high, approximately moving at a straight line (persistence length much larger than the robot's size), at its nominal speed V 0 = v 0 . When walking, the robot moves for a duration τ walk , and then stands for a duration τ stand . The ratio between the two controls the mean speed of the robot when walking V 1 = τ walk τ walk +τ stand V 0 . When τ walk = 0 the robot stands when the photoperceptron fires.

Phototaxis rate for low concentration noninteracting robots estimated using first arrival time

The rate of robot arrival to the light spot at early times (where the lit region is mostly empty), can be found from the reaction rate constant, k, using Smoluchowski first arrival given a number concentration c. In 2D the mean first arrival time, τ F A = 1/kc, of a Brownian particles with diffusion constant D, arriving at a target of size b in an arena of diameter d is given by

k = 2πD log d b . ( 18
)
The rate at which robots are subtracted from the dark region dN bulk dt , is given from a first-order reaction rate

dN bulk dt = -kN bulk , (19)
which solves readily to N bulk = Aexp{-kt}. Given an initial number of robots, N 0 , the number of robots in the light, N , is given from the robot conservation N 0 = N + N bulk ,

N (t) = N 0 1 -e -kt , (20)
which is plotted in Fig. 6.

In-silico results of phototactic swarms

The spatial distribution of a phototactic swarm of aligners and fronters becomes increasingly distinct with increasing swarm size. Figure S2 shows snapshots from simulations of the ad-hoc calibrated phototactic swarm. Showing that fronters fill the lit region, while aligners develop a ring at the perimeter of the light spot, and that the effect grows with swarm size. The effect of morphology becomes more pronounced with growing swarm size also for learning swarms as can be seen in Fig. S3.

Collective learning in a sterically interacting swarm

In this final section, we derive an analytic link between the behavior of individuals in a swarm and the convergence of a decentralized learning scheme. We first establish empirically that a swarm where robots are allowed to collide has good mixing, a property required to establish individual-to-collective correspondence. We then cast collective learning as a dynamical process where robots in the swarm can exchange their state upon encounter. And finally, we show that given the reward function, ρ, as defined in the main text (Eq. 6), a randomly initialized swarm will converge on a successful phototaxis strategy.

Individual dynamics of pre-calibrated robots

The mean time a robot spends in the light spot, Φ, depends on three quantities: 1. The ratio between the speed of the robot in the light V 1 to its speed outside the light, V 0 ; 2. The area fraction of the light spot, σ; 3. Whether or not the robot has the correct threshold for phototaxis. Allowing individual, pre-set robots in the light patterned arena to perform phototaxis shows two distinct behaviors: robots with a correct light threshold for phototaxis spend more time in the lit region than robots with a wrong threshold (either too high or too low, see Fig. S4B) for which time in the light is as good as random Φ W ≈ σ.

Collective dynamics of a pre-calibrated swarm

To test how the speed ratio V 1 /V 0 affects the number of bots in the light, phototaxis experiments were done by increasing the size of the lit region to 25% of the arena. Experiments were performed with either 64 bots or 32 bots (see inset in Fig. S5B). The speed ratio was set by controlling the τ stand as described in Section , changing the speed from standing in light V 1 /V 0 = 0 to effectively being agnostic to the light V 1 /V 0 = 1 (see Fig. S5B). The relative number of robots in the light was tracked over up to 2 hours, and the mean and standard deviation of the last 10% of the experiment duration were used to evaluate the steady-state fraction of the swarm in the light, F ss .

Collective decentralized learning

The collective learning was implemented by deploying a randomly initialized swarm of Morphobots that follow the algorithm detailed below (see Algorithm 1) to give the results presented in Fig. 7 in the main text.

Each robot in the population runs Algorithm 1. This Algorithm builds from the HIT algorithm originally presented in [START_REF] Fontbonne | IEEE Congress on Evolutionary Computation (CEC)[END_REF][START_REF] Yoones | GECCO 2022 -Proceedings of the 2022 Genetic and Evolutionary Computation Conference[END_REF], with two important modifications. Firstly, the algorithm is designed with phototaxis as an objective (the ρ objective function on line 9 measures the amount of light measured in the last T time steps). Secondly, transfer of all control parameters is performed, which implies that whenever a robot receives a parameter set that is deemed to be performing better than its own, this parameter set is fully copied and overwrites existing parameter values. Mutation is not used in this implementation, as the number of robots used (64) and the low dimensionality of the search space (R 2 ) allows for a sufficient amount of behavioral diversity in the initial population of robots (see [START_REF] Fontbonne | IEEE Congress on Evolutionary Computation (CEC)[END_REF] for a comprehensive study of transfer and mutation rate and operators). It should also be noted that the performance assessment (ρ i ) is not reset to zero after a parameter update, which implies that the performance assessment of a newly updated policy is under-estimated for T time steps. While this may temporarily lead to theoretically bestperforming control parameters being overwritten before T steps elapsed, the elitist selection scheme ensures that Finally, note that in the algorithm the observable o contains information about the current light intensity r. They are separated for semantic reasons as o is used as an input value for the policy π, while r is used to update the performance self-assessment ρ i .

Collective learning as a dynamical process

The goal is to link policy and environment to find a route for a successful decentralized learning scheme on average. The time evolution of the probability p i C , respectively p i W , of finding a robot i with a correct, respectively wrong, policy is described by the following master equation :

dp i C dt = ω i C,W p i W -ω i W,C p i C , (21)
where p i W = 1 -p i C and ω i C,W , respectively ω i W,C , are the transition rates at which the robot i with a wrong policy turns into a correct policy and conversely. Defining the concentration of robots with a correct policy as c C , the concentration of robots with a wrong policy is given by c W = c 0 -c C (where c 0 is the constant overall concentration of the swarm). In a system with good mixing, the encounter rate between robots with correct and wrong policy is proportional to the product of their concentrations, kc C c W (to leading order), where k is proportional to mutual diffusion. When encountered, robots compare their rewards and a robot with a wrong policy will adopt the correct policy at a probability f CW . The opposite is also possible (false information scenario) and a robot with a correct policy will adopt a wrong policy at a rate f W C . When combined, the rate equation for the growth in the population with a correct policy becomes

dc C dt = k (f CW -f W C ) c C c W . ( 22
)
Collective learning is achieved when the concentration of robots with correct policy grows, implying: dc C /dt > 0. Since k, c W , and c C are all non-negative, collective learning is guaranteed when f CW > f W C . Given the definition of the reward function in Eq. 6 and the selection protocol defined in Fig. 7, robots with the correct threshold will have, on average, a higher reward, ρ C > ρ W , and the population with the correct policies will prevail (see SM for a full derivation).

We assume space is homogeneous and identify the probability of a given policy for a given robot with the concentration of robots, c C,W , having that policy. Since transition between states happens only through local communication, the transition rates are proportional to the robot encounter rate constant, the latter being independent of the policies of the encountering robots. Under the above hypothesis, the transition rates are proportional to the concentrations and the transition elements read ω C,W ≈ kf CW c C , and symmetrically ω W,C ≈ kf W C c W , where k is the encounter rate, and f CW , respectively f W C , is the transfer probability of W , respectively C, becoming C, respectively W , upon encounter. As a result,

dc C dt = k (f CW -f W C ) c C (c 0 -c C ), (23)
where c 0 is the overall concentration of robots in the arena.

To achieve positive mean collective learning, dc C /dt > 0, the factors of the product in Eq. 23 has to be non negative, which amounts to

f W C > f CW
As learning is decentralized, f is an embedded function and can depend only on information locally accessible to the robot. This includes the robot's policy (here, the weights of its neural network, {w i }), its measurement history, and the message received. Here we exclude a direct functional dependence of f upon the policy as it will artificially bias the learning to a given trait (say turn left) instead of the desired fitness (say measure light). 1Therefore f will depend on some function of the history of its own sensor input and the history of an encountered robot. In our minimal system, the measurement history contains the M most recent light intensity measurements, I i∈1..M (stored as a rolling buffer, i.e FIFO). 2Since the robots have a finite bandwidth, to allow asynchronous performance, where communication does not slow down dynamics, the message should be kept succinct. This means robots should only exchange a reduced version of their memory that can be contained within a message. 3 This will be a function of the memory and will be called the reward function, ρ = ρ ({I i }). 4 In our implementation scheme, robots continuously broadcast a message with their reward and policy; a robot receiving a message compares the Broadcasted reward, ρ B , to its self-reward, ρ S , and if ρ B > ρ S the policy will be deterministically adopted. The question then becomes what functional form does the local ρ take, to satisfy global positive learning on average: ρ C > ρ W .

Empirically we found that in an ad-hoc calibrated swarm at steady state, individual robots with a correct policy spend more time in the light Φ C > Φ W (see Fig. S4), where the mean time in the light of an individual robot is measured by Φ = 1 T 0 -T dtI (t). Identifying the reward function as proportional to the mean time in the light, ρ ∝ Φ allows us to bias the swarm towards learning the correct policy. We do this by computing the reward as the average of the light intensity buffer, ρ = 1 M M i=1 I i (Eq. 6 in the main text).

Recalling that the transfer probability function depends only on the received and embedded reward, the condition for learning simply becomes that on average, correct robots have a greater reward:

ρ C > ρ W (24)
Mean reward in a well-mixed swarm

To satisfy the learning condition presented in the previous section (Eq. 24) we recall the good mixing property found empirically in previous sections wherein the locally computed reward can approximate an individual's time average, which is a proxy to the global performance ρ ∝ Φ ≈ F [START_REF] Ben Zion | [END_REF]. A swarm with good mixing can be modeled as a fluid that obeys the continuity equation:

dC dt = -∇J (25)
where C is concentration and J is the flux. At steadystate, the concentration does not change in time, and so the left-hand side of Eq. 25 vanishes dC dt = 0. In a system made of a collective with spatially varying speed, it has been shown that concentrations are inversely proportional to speeds (see Schnitzer who studied field taxi in bacteria [99]). For the simple case discussed here, space is divided into two regions, lit and dark, where robots have speeds V 1 and V 0 respectively. This results in the following relation of concentration of robots in the light given their speed in the light,

C 0 V 0 = C 1 V 1 , (26)
where C 1 and C 0 are the concentrations of the robots in the light and in the dark respectively. We next derive a link between Eq. 26 and the definition of the swarm fraction in the light, F as defined in Eq. 27 the main text. The concentration of robots in the light, C 1 is the number of robots in the light over the area of the lit region C 1 = N 1 /σA. The concentration of robots in the dark is the remaining number of robots in the swarm, N 0 = N -N 1 over the remaining area of the arena: N 0 /(1-σ)A.

Plugging these into Eq. 26 and rearranging gives,

F ss = 1 V1 V0 1 σ -1 + 1 , (27)
connecting the collective performance (fraction of the swarm in the light), to individual policies (speed ratio), given the environmental condition (fraction of the arena that is lit). For the case of an agnostic swarm, V 0 = V 1 , the swarm does not perform better than random F ≈ σ (consistent with measured performance of individuals Fig. S4 and collectives Fig. S5). When the robots are responsive to the light, V 1 < V 0 , they accumulate in the light spot, and both the individual dynamics (Fig. S4B) and the collective dynamics (Fig. S5B), are also consistent with the above derivation with Eq. 27 setting the high bound for the swarm's performance. When robots are responsive, the swarm accumulates in the light, and individual robots spend more time in the light. Since the reward function as defined in Eq. 6 is proportional to the time a robot spends in the light ρ ∝ Φ, robots that slow down in the light will satisfy the learning condition (Eq. 24), and their superior policy will spread throughout the swarm.

FIG. 1 .

 1 Phototaxis

FIG. 2 .

 2 FIG. 2. Augmenting Kilobots with exoskeletons makes Morphobots.A a Kilobot with a light sensor, IR communication, and two differential drive vibration motors, is fitted into one of two 3D printed exoskeleton designs -(i) fronter, and (ii) aligner. Both fronter B and aligner C exoskeletons are tripods, but the restitution vector, r of the aligners (fronters) is parallel (anti-parallel) to the orientation vector n. D mean square displacement versus time shows the ballistic response for both designs (∝ t 2 ), with a typical speed of 5.2 cm/s (4.8 cm/s) for the aligners (fronters). Also shown, the mean square displacement of a bare Kilobot which after calibration can also move ballistically, but at a speed one order of magnitude slower (0.53 cm/s). Inset: 12-second long trajectories of fronters (green) and aligners (cyan), and a 36-second long trajectory of bare Kilobots (gray) inside the 150 cm diameter arena.

mg sinφ φ 6 o 3 o 0 o 0 o 3 o 6 FFIG. 3 .

 63 FIG.3. The orientation response of aligners and fronters to an external force is equal and opposite. A Sketch of the experimental setup for measuring the dynamical response on an inclined plane (seeMovies 1,[START_REF] Hamann | Swarm Robotics: A Formal Approach[END_REF][START_REF] Brooks | Fast, cheap and out of control[END_REF][START_REF] Dorigo | [END_REF][START_REF] Floreano | From individual robots to robot societies[END_REF]. B Force diagram of a robot placed on an inclined plane. For small slopes (ϕ ≤ 6 • ), robots experience an external body force. C Trajectories of aligners (cyan) and fronters (green) moving on different slopes (ϕ). Aligners and fronters have an opposite response to the external forcealigners' orientation turns downwards as they quickly descend, while fronters turn upwards, and slowly ascend. D Throughout its motion, the orientation of the robot, n, forms an angle θ with the external force, f , together setting the net velocity v (see Eq. 1). E Tracking the orientations shows that aligners turn downhill (θ → 0), aligning with the external force, while fronters turn uphill (θ → π), fronting the external force (see also. Solid curves are fits to Eq. 4, from which κ can be extracted (see SM). F Average fitted κ for each incline angle and robot-design (error bars are the standard error). For finite tilt angle, the response of the two designs is approximately equal and opposite κ aligner = -κ f ronter ≈ 0.3/d. At a slope near zero, the response is dominated by the robot's internal bias (left/right curving and internal noise[54]), but averages to zero. Scale bar is 20 cm.

FIG. 4 .

 4 FIG. 4. Fronters and aligners respond differently to a dynamic environment.A A Morphobot on a swinging table setup for testing morphological response to a dynamically changing environment. B A fronter continually turns uphill, moving in a circular motion while staying on the swinging table (see also supporting Movie 2), whereas an aligner (C) quickly turns downhill and falls off. Top shows schematics, bottom shows measured trajectories. (D) The design rules apply also to custom-made robots (not Kilobot based), producing the expected force alignment response with Morphobots as much as 10 times larger than a Kilobot (see supportingMovies 5,[START_REF] Floreano | From individual robots to robot societies[END_REF]. Scale bars are 10 cm.

  FIG.5. Tuning interaction with a static and a moving obstacle using morphological computation. The morphological interaction of the Morphobots with walls can be explained using their response to an external force. When a Morphobot collides with a wall, each impingement can be seen as a momentary normal force. A Aligners turn to align their orientation (black arrow) with the normal force (red). Once aligned along the wall, there is no further rotation as there are no more collisions, and the robot slides along. B When a fronter collides with a wall, its orientation (black) turns anti-parallel with the normal force (red), and the robot continues to push into the wall. When programmed to run-and-tumble, aligners and fronters interact differently with a wall of stationary robots where aligners (A) cover a much larger distance along the wall relative to fronters (B). C Multiple collision experiments show that aligners and fronters spend similar time near a wall (3τp ≈ 1 min) yet aligners move twice as fast. D Brownian dynamics simulations predict that active particles with a negative alignment parameter, κ < 0 (fronters), push a movable object. E With real robots: placing a round movable obstacle shows that a swarm of fronters is capable of transporting an object. Scale bar is 10 cm.

FIG. 6 .

 6 FIG.6. The collective ability of a robotic swarm to phototaxis is constrained by steric interactions. A A swarm of phototactic robots is placed in an arena patterned with an un-oriented light field. As there are no local gradients to guide a robot to the light source, robots perform a simple run-and-tumble in the dark and stand in the light. B When a fronter arrives at the light spot, it collides with robots already taxied at the perimeter, but progressively pushes its way in. Repeating this process results in the complete coverage of the light spot (C). When an aligner arrives at the light spot (D) it slides along the wall of robots and leaves. This leads to only partial filling of the light spot (E), leaving an empty void in the center. F The resulting fraction of swarm in the light as a function of time shows that at early times (τ ≈ 30τp ≈ 10 mins), both design show equal performance, quantitatively consistent with a diffusion-limited reaction (dashed line). At later times, fronters outperform aligners (average of 4 realizations with error bars being standard deviation). G Simulating swarms with over two orders of magnitude more agents show a sharp slowdown in the phototaxis of aligners with swarm size. H The typical time for half of the swarm to enter the light T 1/2 grows rapidly for an increasingly larger swarm of aligners, while having only a small effect on a swarm of fronters of similar size. Scale bars are 20 cm.

FIG. 7 .

 7 FIG.7. Distributed online reinforcement learning algorithm and deployment of a swarm of Morphobots. A The embedded algorithm for updating the phototactic policy of each robot, is composed of two main moduli: a sense-act cycle and a learning cycle. B The sense-act cycle is encoded into a Perceptron: external stimuli are weighted and summed, evaluated through a sigmoid function, the output of which is binarized to select an action. The weights, w, define the policy π of the robot. C The learning cycle is based on the conditional diffusion of the policies across the population, biased by a reward function ρ evaluated by each robot: when robot 2 receives a message containing the policy control parameters {wi}1 and the reward ρ1 of robot 1, robot 2 will inherit the new policy, if it is associated with a higher reward ρ1 > ρ2. D Illustration of a centralized communication network where all agents (gray circles) are connected to a central operator (red circle). E An illustration of a sparsely connected network where agents communicate only when in close proximity. F1-4 Illustration of a sparse and intermittent communication where a robot (black curve) already in the light source (F1) departs (F2) and broadcasts within communication range (yellow circle) its reward and policy to a robot in the dark (red curve) (F3), which inherits the new policy (F4). Note that the broadcasting robot may have a wrong policy, effectively spreading false information, with neither robot knowing what is the best policy for phototaxis. G A swarm of Morphobots with randomly initialized light thresholds, collectively learns its environment, increasing the swarm fraction in the light. Results are the average of 4 runs with error bars being the standard deviation. Insets show that fronters (top) and aligners (bottom) develop a different spatial arrangement in the highlighted region. H Evolution of the swarm fraction in the light for multi-agent simulations of swarms of different sizes learning to phototaxis using the distributed on-line, reinforcement learning. At earlier times, swarms of fronters and aligners develop the spatial arrangement found in the experiments. At later times (inaccessible experimentally) a swarm of fronters compactly arrange inside the light spot a larger fraction of the swarm in the light compared to the swarm of aligners (see also insets).

Immigrant

  Absorption of Israel. Author contributions: O.D, N.B, and M.Y.B.Z conceived the research. M.Y.B.Z Designed the experiments, theoretical models, and analysis. M.Y.B.Z and J.F performed the experiments and the data analysis. M.Y.B.Z, O.D, and N.B wrote the manuscript. Competing interests: The authors declare no competing interests. Data and materials availability: All (other) data needed to evaluate the conclusions in the article are presented in the article or the Supplementary Materials.

16 )

 16 Phototaxis without learning

Fig. S2 .

 S2 Fig. S2. Snapshots from the phototaxis process of ad-hoc calibrated agents in swarms of size 64, 128, 256, 512 (left to right) of fronters (top) and aligners (bottom). Aligners tend to stop at the perimeter and leave a hollow while swarms of fronters display a more cooperative phototaxis where robots push already taxied robots deeper into the lit region

Fig. S4 .Fig

 S4 Fig.S4. Dynamics and performance of individual pre-programmed robots. A Mean square displacement of the two meta behaviors: the fast run-and-tumble (pink), or the much slower walk-and-tumble (red), with a fixed speed ratio between run and walk. The run-and-tumble behavior transitions from ballistic (∝ t 2 ) to linear (∝ t 1 ) at approximately one persistent time τ ≡ t/τp ≈ 1. Inset shows typical, 20 minutes long trajectories of both run-and-tumble (pink) and walk-and-tumble (red) inside the circular 150 cm wide arena. B The time fraction in the light Φ of an individual robot shows that a robot with too high or too low light threshold performs as well as random, while a robot that has a correct policy, is responsive to the light source. The policy of each robot is determined by the weights of the photo-perceptron, setting the light threshold to activate the photo-perceptron (solid curves).

Algorithm 1 : 2 t = 0 3 while True do 4 o 5 R 6 a 7 act(a) 8 if t > T then 9 ρ 11 if new message then 12 w j ,ρ j = decode message 13 if ρ j > ρ i then 14 w i = w j 15 end 16 end 17 end 18 t = t + 1 19 end 20 end

 1234567891112131415161718120 The phototactic-HIT algorithm Data: i : the unique identifier of the current robot, T : evaluation time, π : Policy function, w i : Random uniform initialisation of policy parameters R[T ] : Empty reward buffer of size T , r : Current light intensity, ρ i : performance self-assessment during T , a : Null action vector, o : Null observation vector1 begin , r = sense() [t mod T ] = r = π(o|w i ) i = T -1 k=0 R[k] 10 broadcast(w i ,ρ i )the original best-performing individual is never lost.

TABLE I .

 I Measured nominal speed and alignment parameter of aligner and fronter designs.

1 1

 1 Gulliver UMR CNRS 7083 ESPCI, PSL Research University, 75005 Paris, France 2 Institut des Systèmes Intelligents et de Robotique Sorbonne Université, CNRS, ISIR, F-75005 Paris, France and 3 School of Physics and Astronomy, and the Center for Physics and Chemistry of Living Systems Tel Aviv University, Tel Aviv 6997801, Israel

	Exoskeleton design

Note that using the policy directly could also be useful if two robots have similar rewards but one has a superior policy (say more energetically efficient). This can also be directly introduced into the reward.

In our case I is an array of bytes and M = 250.

On the Kilobot platform, the message size is 8 bytes.

In our case, ρ will be a single byte.

ACKNOWLEDGEMENTS

We thank Y. Lahini and N. Oppenheimer, and S. Elul. Funding: This work was supported by the MSR project funded by the Agence Nationale pour la Recherche under Grant No ANR-18-CE33-0006. M.Y.B.Z. gratefully acknowledges support from the Ministry of Aliyah and

DATA AVAILABILITY

All data and code required for reproducing the results in the manuscript are found in online repositories [START_REF] Yah | Morphological computation and decentralized learning in a swarm of sterically interacting robots[END_REF].