Darwin World is a 2D ecosystem simulation built with Java and JavaFX. It models a world where animals with genetic codes move, eat, reproduce, and pass traits to their offspring. The simulation runs automatically and shows how populations change through natural selection and mutations based on the initial parameters.
- About The Project
- Media & Gallery
- Ecosystem Mechanics
- World Settings
- Key Features
- Showcase: Fox & Rabbits
- Getting Started
- Built With
This is an autonomous simulation that evolves on its own without player input. The world is a grid divided into fertile jungle areas and harsher steppe areas. Animals spend energy every day and must find food to survive. When they have enough energy, they reproduce and pass a combination of their genes to the next generation, with possible mutations.
*Parameter configuration menu where you set all world settings before launching the simulation.* *Screen for loading built-in presets (for example "fox and rabbits") or choosing your saved configuration.* *Real-time view of the world grid showing animals, plants, energy levels and movement.* *Full interface with live population charts, global statistics and detailed tracking of a selected animal (genotype, energy, lineage, etc.).*
Watch the full simulation in action (screen recording):
simulation_demo.mp4
- Herbivores: Move around the map searching for plants. Plants provide different amounts of energy when eaten.
- Carnivores: Hunt other animals. A carnivore can eat another creature if the energy difference between them is sufficient.
- Crossbreeding: Breeding is possible between herbivores and carnivores, animal with bigger energy determines the type of child.
Every animal has a genome consisting of 8 genes (numbered 0 to 7), each representing a movement direction. Each day, the active gene determines the direction the animal turns before moving forward. After the move, the next gene in the sequence becomes active.
Animals on the same tile with enough energy will mate. The offspring's genome is created by combining genes from both parents in proportion to each parent's current energy level. A random number of genes then mutate.
Before starting the simulation you can configure the world parameters in the dedicated menu. These settings define the initial conditions and rules of the ecosystem:
- Width / Height — width and height of the simulation grid.
- startNumberOfPlants — initial number of plants placed on the map at the start.
- numberOfCarnivores — initial number of carnivores.
- numberOfHerbivores — initial number of herbivores.
- plantsSpawnPerDay — number of new plants that appear on the map each day.
- Refresh Rate (ms) — time interval in milliseconds between visual updates of the simulation.
- startEnergy — starting energy level for every newly created animal.
- genesLength — length of each animal’s genome (number of genes).
- energyForTheDay — energy cost an animal spends per day (movement cost).
- energyToReproduce — minimum energy an animal must have to be able to reproduce.
- Minimal number of mutations — minimum number of genes that can mutate in the offspring.
- Maximal number of mutations — maximum number of genes that can mutate in the offspring.
- energyThreshold (Carnivore) — minimum energy difference required for a carnivore to eat another animal.
- minEnergy / maxEnergy (Plant) — minimum and maximum energy a plant can provide when eaten (actual value is chosen randomly within this range).
The project includes several built-in presets. You can save your own configurations to files and load them later.
- The grid automatically scales to fit the window regardless of the map dimensions.
- Animals display visual indicators (color or bar) showing their current energy level.
- Support for running multiple independent simulations simultaneously in separate windows.
- Click any animal to select it. The sidebar shows real-time information: full genotype, active gene index, energy level, number of eaten plants, age, and lineage (direct children and total descendants).
- Main dashboard displays global statistics: total animals and plants, number of carnivores and herbivores, free cells, average lifespan, average children number and dominant genotypes.
- Interactive charts: selecting any metric in the World Statistics panel generates a live historical graph of that parameter over time.
- Daily simulation statistics are automatically exported to a CSV file for analysis in Excel or Python.
- Save and load custom world settings.
- Several built-in presets for different scenarios.
Load the fox and rabbits preset to see the interaction between carnivores and herbivores.
In this configuration the following cycle occurs:
- The rabbit population grows when plants are abundant.
- The fox population increases because more food is available.
- Intensive hunting reduces the rabbit population.
- Foxes begin to starve and their numbers decrease.
- With fewer predators the rabbit population recovers, and the cycle repeats.
- Java JDK 17 or higher
- Gradle or Maven (depending on your build system)
-
Clone the repository: git clone https://github.com/your-username/darwin-world.git
-
Navigate to the project directory: cd darwin-world
-
Run the application via your IDE or build tool (e.g. Gradle): ./gradlew run
-
In the main menu create your own configuration or load one of the presets and Click Start Simulation
- Core Logic: Pure Java (OOP)
- GUI: JavaFX
- Concurrency: Java multi-threading for independent simulation instances



