## 5 Dynamic Prey-Predator Spatial Model via African Buffalo Optimization
### Season Definition
#### 5.3.2 Migration  
At this stage, the predators (_buffaloes_) move within the space of the lattice according to the individual experience of each buffalo and the experience of the herd. To perform the migration of each predator, the new position (x, y) is calculated according to Equations (9)-(12). The description of this procedure is detailed in Algorithm 4. \[m_{x}^{k+1}=m_{x}^{k}+lp1(bgmax_{x}-w_{x}^{k})+lp2(bpmax_{x}^{k}-w_{x}^{k}) \tag{9}\]  
\[m_{y}^{k+1}=m_{y}^{k}+lp1(bgmax_{y}-w_{y}^{k})+lp2(bpmax_{y}^{k}-w_{y}^{k}) \tag{10}\]  
\[w_{x}^{k+1}=\frac{(w_{x}^{k}+m_{x}^{k})}{\pm\lambda} \tag{11}\]  
\[w_{y}^{k+1}=\frac{(w_{y}^{k}+m_{y}^{k})}{\pm\lambda} \tag{12}\]```
Input : Lattice, \(lp1,lp2,lambda,bgmax_{x},bgmax_{y}\). Output : Lattice, \(bgmax_{x},bgmax_{y}\). 1 for all predators \(j\) in the latticedo \(predator_{j}\leftarrow\text{Get }predator_{j}\) in the lattice. \(m_{x},m_{y}\leftarrow\text{Get }m_{x},m_{y}\) value from \(predator_{j}\). \(bpmax_{x},bpmax_{y}\leftarrow\text{Get }bpmax_{x},bpmax_{y}\) value from \(predator_{j}\). \(w_{x},w_{y}\leftarrow\text{Get }w_{x},w_{y}\) value from \(predator_{j}\). \(new\_m_{x}\leftarrow\text{Calculate }new\_m_{x}\) value using Equation (9). \(new\_m_{y}\leftarrow\text{Calculate }new\_m_{y}\) value using Equation (10). \(new\_w_{x}\leftarrow\text{Calculate }new\_w_{x}\) value using Equation (11). \(new\_w_{y}\leftarrow\text{Calculate }new\_w_{y}\) value using Equation (12). Convert point (\(new\_w_{x}\), \(new\_w_{xy}\)) to point for torus lattice. ifpredator\({}_{j}\) status is equal to 2 or 3 then if\(lattice[new\_w_{x}][new\_w_{y}]\) value is equal to 0 then \(lattice[new\_w_{x}][new\_w_{y}]\leftarrow\text{Set status 2}\). Set \(predator_{j}\) status to 2.  end if if\(lattice[new\_w_{x}][new\_w_{y}]\) value is equal to 1 then \(lattice[new\_w_{x}][new\_w_{y}]\leftarrow\text{Set status 3}\). Set \(predator_{j}\) status to 3.  end if  Update the positions (x,y) with the (\(new\_w_{x}\), \(new\_w_{y}\)) values in the \(predator_{j}\). Update the \(w\) (\(w_{x},w_{y}\)) values with the (\(new\_w_{x}\), \(new\_w_{y}\)) values in the \(predator_{j}\). end if  Update \(bgmax_{x}\) and \(bgmax_{y}\) using Algorithm 3. ```

**Algorithm 4**Migration. ### Reproduction of Predators

At this stage, predators breed by creating new individuals at random within the neighborhood by Equation (13). The description of this procedure is detailed in Algorithm 5. \[M_{r_{z}}=(2r_{z}+1)^{2} \tag{13}\]

#### 5.4.1 Death of Predators

Predators that do not have a prey in their own cell die from starvation (cellular automata with status equal to 2). The description of this procedure is detailed in Algorithm 6. ```
input :Lattice. output :Lattice. 1 for all predators \(j\) in the latticedo
2\(predator_{j}\leftarrow\) Get predator \(k\) in the lattice; \(x\leftarrow\) Get \(x\) value of the predator\({}_{j}\). 3\(y\leftarrow\) Get \(y\) value of the predator\({}_{j}\). 4 ifpredator status is equal to 2 then
5\(lattice[x][y]\leftarrow\) Set status 0. 6 end if
7
8 end for
9
10 end for
```

**Algorithm 5**Reproduction of predators. #### 5.4.2 Predation

All the prey that share a cell with a predator die due to the action of the predator (cellular automata with state equal to 3). The description of this procedure is detailed in Algorithm 7. ```
input :Lattice. output :Lattice. 1 for all predators \(j\) in the latticedo
2\(predator_{j}\leftarrow\) Get predator \(k\) in the lattice; \(x\leftarrow\) Get \(x\) value of the \(predator_{j}\). 3\(y\leftarrow\) Get \(y\) value of the \(predator_{j}\). 4 ifpredator status is equal to 3 then
5\(lattice[x][y]\leftarrow\) Set status 0. 6
7 end if
8
9 end for
```

**Algorithm 7**Predation. #### 5.4.3 Reproduction of Preys

Each prey creates new individuals randomly within the neighborhood. The description of this procedure is detailed in Algorithm 8. ```
for all prey in the latticedo
1 ifprey status is equal to 1 then
2\(birth\_count\gets 0\).