ASCII Spatial Predator-Prey (Lotka-Volterra)

Share script: curl https://example.invalid/alife/predator_prey.py | python3


  

    
📖 About the Predator-Prey Model (Lotka-Volterra spatial)
This cellular automaton models population dynamics and ecological balance in a spatial grid, inspired by the classic Lotka-Volterra differential equations.

The Rules:
The grid consists of three states: Empty (Black), Prey (Green), and Predators (Red).
1. Prey reproduce randomly into adjacent empty spaces.
2. Predators hunt prey (turning a prey cell into a predator). If they don't eat, they slowly starve and die (turning into an empty cell).

Instead of settling into a static state, the system usually forms dynamic, self-sustaining spirals and waves. When prey is abundant, predators multiply rapidly and consume them. The resulting prey shortage causes the predator population to collapse, allowing prey to recover, and the cycle continues indefinitely. It beautifully visualizes the fragile, oscillating balance of natural ecosystems.