This model simulates a population of creatures, represented as dots. They have various properties such as health, speed, and directional biases. Since they live on a 2d plane, they only have left/right and up/down; so we apply random directional biases and other properties to simulate heterogeneity in the first generation. The simulation introduces selection pressures, this requires the user to toggle one of the 4 quadrants of the 2d plane. This area will become "dangerous", it will remove their health and ultimately kill any creatures who have the directional bias to move toward it. Each generation lasts 8 seconds as a default, although values can be changed. As you would expect, the creatures who die likely had the genes that caused them to tend toward the dangerous quadrant, the ones that survived had directional biases away from the dangerous quadrant - hence the next generation is likely to aquire that favorable gene. Try for yourself, and have fun (:
- Randomized Creature Attributes: Each creature is initialized with random health, speed, and directional biases.
- Movement System: Creatures move across the simulation area with a bias in both the X and Y directions.
- Natural Selection: Creatures reproduce after a set time period, with offspring inheriting attributes from their parents.
- Interactive Quadrants: Users can toggle damage in different quadrants of the simulation area by clicking, simulating environmental pressures.
- Real-time Statistics: The average health, speed, directional bias, and the number of living creatures are displayed and logged for each generation.
- Python 3.x
- Pygame
pip install pygame
orpy -m pip install pygam
e orpython -m pip install pygame
- Clone the Repository:
git clone https://github.com/hm0809/selection.git cd selection