Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/azcobu/lotka-volterra
Simulating the Lotka-Volterra predator/prey relation.
https://github.com/azcobu/lotka-volterra
Last synced: 24 days ago
JSON representation
Simulating the Lotka-Volterra predator/prey relation.
- Host: GitHub
- URL: https://github.com/azcobu/lotka-volterra
- Owner: Azcobu
- Created: 2022-02-06T00:46:20.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-04-13T02:17:16.000Z (over 2 years ago)
- Last Synced: 2023-11-22T07:35:22.794Z (12 months ago)
- Language: Python
- Size: 178 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Lotka-Volterra
This simple simulation shows how complex behaviour can arise from a very simple set of initial rules. In this case, the sim models the predator-prey relationship and demonstrates the mutually inter-related population dynamics modelled by the [Lotka-Volterra equations](https://en.wikipedia.org/wiki/Lotka%E2%80%93Volterra_equations).The sim in action:
![Screen](/img/lotvolt-screen.jpg?raw=true "Screen")
## Rules
Each site has three states: wolf, sheep or empty.1. Pick a site (only stochastic updates allowed), and a neighbour.
2. If a wolf is adjacent to a sheep, the sheep gets eaten (becomes wolf with probability r). Otherwise the wolf dies with probability p.
3. If a sheep is adjacent to empty ground, it reproduces with probability q.
4. If empty ground is adjacent to anything, the thing moves into empty ground.Other assumptions - there is an unlimited supply of grass for the sheep to eat, sheep only die from wolves, and wolves only eat sheep.
The sim is run for 5000 ticks, or until one species goes extinct, whichever comes first. A plot showing populations for the two species is then displayed:
![Plot](/img/lotvolt-graph.png?raw=true "Plot")
The complex mututal relationship between predator and prey numbers is clearly shown here, with every great population boom for one side or the other followed by an equal crash.
### Other variants
I also wrote a version where the sheep were also constrained by limited food. In this version, grass was not infinite, but disppeared when eaten, and only regrew over time. This forced the sheep to constantly migrate in search of food. However, this variant resulted in a sharply-reduced sheep population (as you would expect) and a wolf population that was so low the sim usually ended fairly quickly.