# The Role of Sensory Cues in Collective Dynamics: A Study of Three-Dimensional Vicsek Models
## 2 Methods
### Implementation of the Algorithm  
The modified three-dimensional version of the Vicsek model, implementing three modalities, is presented in Algorithm 1. The computational cost of the Vicsek model is largely dependent on the number of particles, the radius of interaction, and the size of the domain. The primary computational cost arises from identifying neighbors within the radius of interaction \(r\) for each particle and updating their velocities and positions. Each particle compares its position with every other particle to determine neighbors, leading to a computational complexity of \(\mathcal{O}(N^{2})\). This becomes computationally expensive for large-scale systems. Once neighbors are identified, updating the velocity and position of each particle is computationally inexpensive. The velocity update involves the average direction calculation by summing the velocities of neighbors and adding noise. This operation is linear in the number of neighbors (\(\mathcal{O}(N_{\text{neighbors}})\) ). Updating positions based on velocity is a constant-time operation (\(\mathcal{O}(1)\)). For \(N\) particles, the total computational cost of updates is \(\mathcal{O}(N)\) per time step.  
```
Input:\(N\) (number of particles), \(L\) (domain size), \(r\) (interaction radius), \(\phi\) sensing half-angle, \(\eta\) (noise), \(v\) (speed), \(T\) (time steps)
1 Positions \(X[i]\in[-L/2,L/2]^{3}\), Directions \(\mathbf{d}[i]\in\mathbb{R}^{3}\) with \(\|\mathbf{d}[i]\|=1\);
2 Velocities \(V[i]=v\cdot\mathbf{d}[i]\);
3 for\(t=1\)to\(T\)do
41. Neighbor Search: \({}^{V}\Lambda_{i}\leftarrow\{j\mid\text{distance}(X[i],X[j])\leq r\text{ and }\arccos\left(\frac{\mathbf{d}[i]:(X[j]-X[i])}{\|X[j]-X[i]\|}\right)\leq\phi\}\) under periodic boundaries (visual neighbors);
4\({}^{A}\Lambda_{i}\leftarrow\{j\mid\text{distance}(X[i],X[j])\leq r\text{ and }\arccos\left(\frac{\mathbf{d}[j]:(X[j]-X[i])}{\|X[j]-X[i]\|}\right)\leq\phi\}\) under periodic boundaries (auditory neighbors);
4\(\Lambda(i)\leftarrow{}^{V}\Lambda_{i}\) (visual mode)
5\(\Lambda(i)\leftarrow{}^{A}\Lambda_{i}\) (auditory mode)
6\(\Lambda(i)\leftarrow{}^{V}\Lambda_{i}\cup\LambdaLambda_{i}\) (composite mode)
62. Update Directions:  Compute the average direction of neighbors.; \(\mathbf{d}_{\text{avg}}\leftarrow\frac{\sum_{j\in\Lambda(i)}\mathbf{d}[j]}{\| \sum_{j\in\Lambda(i)}\mathbf{d}[j]\|}\);
7 Add random noise:;
8\(\mathbf{d}[i]\leftarrow\mathbf{d}_{\text{avg}}+\mathbf{n}\), where \(\mathbf{n}\sim\text{Uniform}(-\eta/2,\eta/2)\);
9 Normalize the updated direction.;
10\(\mathbf{d}[i]\leftarrow\frac{\mathbf{d}[i]}{\|\mathbf{d}[i]\|}\);
11
123. Update Velocities and Positions: \(V[i]\gets v\cdot\mathbf{d}[i]\); \(X[i]\leftarrow(X[i]+V[i]\Delta t)\mod L\);
13
14 end for Output: Positions \(\mathbf{X}\) and velocities \(\mathbf{V}\).
```  
**Algorithm 1**3D Vicsek Model pseudo-code for auditory, visual and composite modes  
Periodic boundary conditions ensure that computational complexity depends only on particle density, as domain size does not affect dynamics. Note that, as particle density increases, the number of neighbors within the sensing region also increases, affecting the computational cost of neighbor searches and updates. Reducing the sensing region from a sphere to a cone decreases the number of neighbors, thereby lowering the computational cost of our auditory/visual modification of the Vicsek model compared to the original version.  
The memory usage is proportional to \(\mathcal{O}(N)\) for storing particle positions and velocities, and \(\mathcal{O}(N_{\mathrm{neighbors}})\) for maintaining neighbor lists.