This is a project that was made as a part of an Object-Oriented Programming course at university. Students need to get random extra operations. In this project extra operation was:
- Life-giving corpses - plants prefer to grow on fields when an animal has died before.
- Minor correction - mutation change a genom by +1 or -1 (-1 overlap to 7).
- Simulation world - is a rectangle divided to small square fields. If animal want to pass the border they will be teleported to opposite site of map.
- Animal - they are herbivores with different genotype and they move in the world. They get energy for eating plants and can breed with each other or evolve.
- Genotypes - this is a set of genomes that control movements of animals. Each animal has their own genotype. Genotype can change after mutation or child has a genotype that is mix of parents genotypes. Animal can move in 8 directions (so genotype has number in range of 0 to 7).
- Interaction with world - animals can eat plants and plants grow up constantly.
- Simulation - simulation is divided to day cycle in each day animals move, eat plant, breed and mutate.
- Competition - if there are more than 2 animal of field, they compete for plant or the right to breed. This conflict is resolved in particular order:
- Animals with the most energy
- Animals that are the oldest
- Animals with the highest number of children
- Random selection
Before each simulation there are some settings that can be set for each simulation. These settings are:
- width and height of the map (simulation world)
- map variant
- starting numbers of plants
- energy received from eating a plant
- number of plants growing each day
- plant spawning variant (including life-giving corpses)
- starting number of animals
- starting energy for each animal
- energy required for breeding
- amount of parents’ energy used to create a child
- minimum and maximum number of mutations
- mutation variant
- genotype length
- animal behavior variant
Each of simulation settings can be saved to JSON file and be reused again for next simulation. Each saved simulation we need to pass name.
In each simulation is a user interface that shows current simulation statistics. These statistics are:
- number of animals
- number of plants
- number of free fields
- most common genotype
- average energy of living animals
- average lifespan of all animals that have died
- average number of children of living animals
When the simulation is paused, the user can select an individual animal and inspect its statistics. When the simulation resumes, a separate panel shows live updates for the selected animal, including:
- genotype
- currently active gene
- total energy
- number of eaten plants
- number of children
- number of descendants (children, grandchildren, etc.)
- total days alive
- death day (if the animal is dead)
There is also a button to highlight animals with most popular genotype.
Below are example screenshots of the simulation:

- Java
- JavaFx - used to create user interface
- Maven - tool to build and run project with dependencies
- JUnit5 - tests
src/main/java/org/project/
- apps/ // JavaFX application entry points
- enums/ // enums files
- generators/ // generators for grass or genotypes (with abstract classes)
- model/ // core domain classes (animals, maps, grass, stats)
- presenter/ // controllers for views
- Simulation.class // main simulation engine
- Execute.class // entry point with the main() method
- Java 23+
- Maven 3.9+
- JavaFX (downloaded automatically by Maven)
mvn clean install
mvn javafx:run