## 4 The Experiments  
### Experiment A: Leader Selection  
The objective of the leader selection experiment is to find a cooperative behavior in which just a single agent claims the leadership of the group during the evaluation period. Robots can claim leadership by turning their LED on. Cooperative solutions resulting in the swarm leader being the same during consecutive time instants will be rewarded, trying to avoid unnecessary switching of the leadership. However, it is highly desirable to find a swarm behavior capable of reacting to leader fault or loss by selecting a substitute. In order to guide evolution towards this behavioral feature, a robot becomes faulty if it has been the unique leader for 50 consecutive simulation cycles. In this context, a faulty robot means that the agent can only relay input messages (it is always in relay mode) and it cannot claim leadership. As communication is still operative after failure, the swarm graph cannot be broken or disconnected due to leader fault. The size of the swarm or the number of robots in \(\mathcal{R}\) is set to 10, albeit there is a post evolution scalability analysis assessing the task for \begin{table}
\begin{tabular}{c c c} \hline \hline
**Variable** & **Min.** & **Max.** \\ \hline
**w** & \(-3\) & \(3\) \\ \(\tau\) & \(-1\) & \(0.75\) \\ \(\beta\) & \(-1.5\) & \(1.5\) \\ \(\mathbf{g}\) & \(0.05\) & \(5\) \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Search space constrains of each of the denormalized optimization variables. different swarm sizes. At the beginning of each simulation episode, the robots' position are randomly initialized with a random spatial graph initializer that guarantees that there are no isolated swarm members. Heading orientations are also randomly initialized. The fitness function rewards two main aspects of the swarm behavior in this problem, namely, leader identification and its preservation. On the one hand, the instantaneous fitness score increases at each time step when there is uniquely one leader in the group. On the other hand, the reward rises proportionally to the number of consecutive time steps that the leadership has been assumed by the same robot. The fitness function at each simulation instant is exposed in Equation (12). \[f_{A}(\mathcal{G},k)=\mathbf{w}(k)^{\top}\mathbf{a}_{LED}(k) \tag{12}\]  
The vector \(\mathbf{a}_{LED}(k)\in\{0,\,1\}^{R}\) gathers the LED actions performed by all the agents in the swarm at time step \(k\), subject to genotype \(\mathcal{G}\). Moreover, \(\mathbf{a}_{r,LED}(k)\) is the scalar LED action of the robot \(r\) in the group (which is one of the components of \(\mathbf{a}_{LED}(k)\)). The vector \(\mathbf{w}(k)\) is a credit assignment vector that represents the number of consecutive time steps that a robot has been the leader. \[\mathbf{w}(k)= \begin{cases}\min\{\mathbf{w}(k-1)+0.1\,\mathbf{a}_{LED}(k),\,5 \}&\quad\text{If }\sum_{r\in\mathcal{R}}\mathbf{a}_{r,LED}(k)=1\\ &\quad\text{and }\mathbf{a}_{LED}(k)=\mathbf{a}_{LED}(k-1)\\ \\ 0.1\,\mathbf{a}_{LED}(k)&\quad\text{If }\sum_{r\in\mathcal{R}}\mathbf{a}_{r, LED}(k)=1\\ &\quad\text{and }\mathbf{a}_{LED}(k)\
eq\mathbf{a}_{LED}(k-1)\\ \\ (\underbrace{0,\ldots,0}_{R\text{ times}})^{\top}&\quad\text{Otherwise}\end{cases}  \tag{13}\]  
Specifically, Equation (13) describes the computation of \(\mathbf{w}(k)\). Note that the components corresponding to activated LEDs are increased 0.1 up to a maximum of 5. This increment is only performed if there is only one leader (i.e., only one LED action to 1) and the current leader is the same as the previous one, as specified in the condition of the equation. Alternatively, if there is only one leader but it is not the same as the previous one (or there was not a leader) then the credit assignment is 0.1. Provided that none of the former conditions are fulfilled, the credit assignment vector is reset to zeros. With the meaning of \(\mathbf{w}(k)\) in mind, we can resume the explanation of Equation (12).