You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Predator-Prey Cellular Automaton: Model Documentation
1
+
##Predator-Prey Cellular Automaton: Model Documentation
2
2
3
-
## Overview
3
+
###Overview
4
4
5
5
This project impelments a spatial predator-prey cellular automaton (CA) to investigate the Hydra effect, a counterintuitive ecological phenomenon where increased prey mortality paradoxically leads to higher prey population densities. The model explores the rise of emergent population dynamics through spatial structure and local interactions that differe fundemntally from well-mixed (mean-field) predictions.
6
6
7
7
The codebase uses Numba JIT compilation for computationally intensive kernels and is tuned for high performance computing environments. It supporrs parameter sweeps, finite size scaling analysis, and self-organized criticality exploration.
8
8
9
9
---
10
10
11
-
## Background
11
+
###Background
12
12
13
-
### The Hydra Effect
13
+
####The Hydra Effect
14
14
15
15
In classical Lotka-Volterra dynamics, increasing prey mortality always reduces the prey population. However, theoretical work has identified conditions where the opposite effect can be observed. The Hydra effect emerges in spatially structured systems where
16
16
@@ -20,7 +20,7 @@ In classical Lotka-Volterra dynamics, increasing prey mortality always reduces t
20
20
21
21
This study uses a cellular automaton framework toi study how spatial strcuture generates the Hydra effecr and whether the system exhibits signatures of self-organized criticality at the transition point.
22
22
23
-
### Self-Organized Criticality (SOC)
23
+
####Self-Organized Criticality (SOC)
24
24
25
25
SOC refers to systems that naturally evolve toward a critical state without external tuning. At criticality, such systems exhibit:
26
26
@@ -33,9 +33,7 @@ In the predator-prey context, SOC would manifest as the system self-tuning towar
33
33
34
34
---
35
35
36
-
## Model Description
37
-
38
-
### State Space
36
+
### Model Description
39
37
40
38
The model uses a 2D lattice with periodic boundary conditions. Each cell occupies one of three states:
41
39
@@ -45,26 +43,18 @@ The model uses a 2D lattice with periodic boundary conditions. Each cell occupie
45
43
| Prey | 1 | Prey organism |
46
44
| Predator | 2 | Predator organism |
47
45
48
-
### Transition Rules
49
-
50
46
The model uses asynchronous updates: cells are processed in random order each timestep, with state changes taking effect immediately. This prevents artificial synchronization artifacts common in parallel update schemes.
51
47
52
-
#### Prey Dynamics
53
-
54
48
For each prey cell, in order:
55
49
56
50
- Death: With probability `prey_death`, the prey dies and the cell becomes empty
57
51
- Reproduction: If alive and a randomly selected neighbor is empty, with probability `prey_birth`, a new prey is placed in that neighbor cell
58
52
59
-
#### Predator Dynamics
60
-
61
53
For each predator cell, in order:
62
54
63
55
- Death: With probability `predator_death`, the predator dies (starvation)
64
56
- Hunting/Reproduction: If alive and a randomly selected neighbor contains prey, with probability `predator_birth`, the predator consumes the prey and reproduces into that cell
65
57
66
-
### Neighborhood
67
-
68
58
The model supports both neighborhood types:
69
59
70
60
- Moore neighborhood: (default): 8 adjacent cells (including diagonals)
@@ -74,11 +64,11 @@ Moore neighborhoods are used throughout the experiments as they provide more rea
74
64
75
65
---
76
66
77
-
## Hunting Modes
67
+
###Hunting Modes
78
68
79
69
The model implements two distinct neighbor selection strategies that qualitatively affect dynamics.
80
70
81
-
### Random Neighbor Selection (Default)
71
+
####Random Neighbor Selection (Default)
82
72
83
73
In the standard mode, each organism selects a single random neighbor for interaction:
84
74
@@ -94,7 +84,7 @@ if grid[neighbor] == PREY and random() < predator_birth:
94
84
```
95
85
This creates a blind interaction model where organisms are not aware of their surroundings.
96
86
97
-
### Directed Hunting Mode
87
+
####Directed Hunting Mode
98
88
99
89
The directed mode implements "intelligent" neighbor selection:
100
90
@@ -119,9 +109,9 @@ This increases the effective reproduction and predation rates without changing t
The model supports per-cell parameter evolution, where offspring inherit (with mutation) their parent's parameter values:
176
166
@@ -188,9 +178,7 @@ When evolution is enabled, each prey cell maintains its own `prey_death` value.
188
178
189
179
---
190
180
191
-
## Numba Optimization
192
-
193
-
### Performance Strategy
181
+
### Numba Optimization
194
182
195
183
The computational bottleneck is the update kernel, which must process every occupied cell each timestep. For a 1000×1000 grid with 50% occupancy, this means ~500,000 cell updates per step.
196
184
@@ -201,7 +189,7 @@ Key optimizations:
201
189
3.**Efficient Shuffling**: Fisher-Yates shuffle implemented in Numba for random cell ordering
202
190
4.**Cell Lists for PCF**: Pair correlation functions use spatial hashing for O(N) instead of O(N²) complexity
203
191
204
-
### PPKernel Class
192
+
####PPKernel Class
205
193
206
194
```python
207
195
classPPKernel:
@@ -223,8 +211,6 @@ class PPKernel:
223
211
```
224
212
---
225
213
226
-
## Analysis Methods
227
-
228
214
### Cluster Detection
229
215
230
216
Clusters are contiguous groups of same-species cells (using Moore connectivity). The implementation uses stack-based flood fill with periodic boundary conditions.
0 commit comments