Darwin World is an object-oriented simulation of evolution inspired by Land of Lisp and Genetic Algorithms and Their Applications.
The project visualizes how populations of animals evolve over time in a dynamically changing environment.
The goal of this project is to create a simulation world where:
- Animals move around a 2D map,
- Search for food,
- Consume plants to survive,
- Reproduce and pass on genes,
- Mutate over generations,
- And eventually evolve into different species.
The simulation runs automatically and visualizes the process of natural selection over thousands of generations.
The world is a rectangular grid of square fields:
- Most of the map is steppe (normal plant growth).
- Some fields become fertile areas where plants grow faster based on animal activity.
Animals are herbivores and rely on plants as their only energy source.
Each animal is defined by:
- Position (x, y) – location on the map
- Energy – decreases daily, increases after eating plants
- Orientation – one of 8 possible directions
- Genes – sequence of numbers (0–7) determining movement behavior
If an animal’s energy reaches 0, it dies.
When an animal stands on a field with a plant:
- The plant is consumed
- The animal gains a predefined amount of energy
Two animals on the same field may reproduce if they have enough energy:
- Parents transfer part of their energy to the child
- The child receives a mixed genotype from both parents
- Random mutations are applied
Each simulation day consists of:
- Removing dead animals
- Turning and moving all animals
- Animals eating plants on their fields
- Reproduction of strong animals on the same field
- Growing new plants
- Updating soil fertility
- Left and right edges wrap around
- Top and bottom edges are poles:
- Animals cannot move beyond them
- Attempting to do so reverses their direction (180°)
Instead of a static jungle, fertile areas are created dynamically.
- When a strong animal (energy ≥
minCultivateEnergy) steps on a field:- The field's visit counter increases
- After reaching
cultivateLimitvisits:- The field becomes fertile for
fertileDays
- The field becomes fertile for
- 80% chance on fertile fields
- 20% chance on normal steppe fields
- Fertility decreases over time if not cultivated again
During reproduction:
- A random number of genes are selected
- Each selected gene is replaced with a random value from 0 to 7
- Language: Java 25
- Build Tool: Gradle
- GUI: JavaFX
- Testing: JUnit 5
- Clone the repository
- Make sure Java 25 is installed
- Build and run using Gradle:
./gradlew run

