## 4 The Algorithms
### Space Exploration/Monitoring Roles  
State 2 in Figure 2 represents the space exploration/monitoring role. The exploration space \(S_{real}\) is divided into regular cubic cells. The agent can move into one of the neighboring cells (3D Moore or Neumann neighborhood) or stay where it is (in the case of a collision) in every iteration of the time \(t\). The movements of the agents that perform the exploration or monitoring tasks, are controlled by the following rules. The rules were adapted from a 2D scenario, described in our previous research [35], to a 3D scenario:  
1. If the agent's neighboring cells contain at least some non-zero pheromone values, the agent attempts to find the neighboring cell with the lowest pheromone value \(min(Pex_{n}(a,b,c)(t))\), \(a\in<x-1,x+1>\), \(b\in<y-1,y+1>\), \(c\in<z-1,z+1>\bigvee\text{cell}(a,b,c)\in s_{\{n,i\}}\). If there are multiple cells with the same low level of pheromones, then the agent chooses one of these cells at random. The agent moves to the selected cell in the next iteration if it does not conflict with other agents.
2. If the cells neighboring the agent have only zero pheromone values, then the agent chooses at random one of these cells and stores the direction \(RD\) it has decided to move to. The agent then continues to move in the chosen direction \(RD\), \(RD\in<1,Z^{+}>\) in the next iterations until its neighboring cells contain only zero pheromone values and if it does not conflict with other agents.
3. If two or more agents intend to move into the same cell\((x,y,z)\), a conflict occurs. In this situation, one of the agents is chosen randomly as a winner and it moves to the given cell in the next iteration. All the remaining agents participating in the conflict stay in their positions and wait for the next random tournament.  
When an agent \(a_{\{f,k,v\}}\) visits a cell(\(x\),\(y\),\(z\))\(\in s_{\{k,f\}}\), it leaves there a pheromone mark \(Pmax_{\{f,k,v\}}\). This information is recorded into the internal map of the agent \(S_{a_{\{f,k,v\}}}\) as well. Let us take a cell(\(x\),\(y\),\(z\)) \(\in s_{\{k,v\}}\), then the value of the pheromone mark \(Pex_{k}(x,y,z)(t)\) in the cell(\(x\),\(y\),\(z\)) of the \(S_{real}\) or internal agent map \(S_{a_{\{f,k,v\}}}\) at the time \(t\) is calculated as  
\[R(x,y,z)(t)=\begin{cases}0&\text{agent is not in the cell}(x,y,z)\text{ in the time }t\\ 1&\text{agent is in the cell}(x,y,z)\text{ in the time }t\end{cases}, \tag{5}\]  
\[Pex_{k}(x,y,z)(t)=\begin{cases}Pmax_{\{f,k,v\}}*R(x,y,z)(t)&\\ &\text{if }Pex_{k}(x,y,z)(t-1)==0\\ Pmax_{\{f,k,v\}}*R(x,y,z)(t)+Pex_{k}(x,y,z)(t-1)-1\\ &\text{if }Pex_{k}(x,y,z)(t-1)>0\end{cases}. \tag{6}\]The parameter \(Pmax_{\{f,k,v\}}\) represents the initial level of the pheromone mark. It is calculated at the start of the algorithm and it depends on the size of the exploring space. We have established in previous experiments that \(Pmax_{\{f,k,v\}}\) should be equal or greater than the number of the cells in the exploration space \(s_{\{k,f\}}\)[38]. The equations above are valid for all the cells of the \(S_{real}\) or \(s_{a_{\{f,k,v\}}}\). The parameter \(R(x,y,z)(t)\) represents an agent's localization matrix in the space \(S_{real}\).