Darwin World is a sophisticated stochastic simulation of an evolving biological ecosystem. Inspired by evolutionary theories and biological concepts, the project models a virtual world where entities (Animals) compete for resources (Plants), reproduce, and pass on genetic information under varying environmental pressures.
The simulation operates on a discrete 2D grid where every element follows specific biological and physical rules designed to observe emergent evolutionary patterns.
The environment is divided into zones with different fertility levels:
- Fertility Zones: The map features Steppes (low fertility) and a central Equator/Jungle (high fertility).
- The Pareto Principle: To simulate realistic resource distribution, 80% of new plants sprout in the Jungle (occupying 20% of the map), while the remaining 20% appear in the Steppes.
- Geometry: The map behaves (almost) like a globe — it is toroidal on the X-axis (warp-around), and animals bounce off the North and South poles, reversing their direction.
Each animal is an autonomous agent defined by its position, energy level, and Genotype.
- Movement: Orientation is based on 8 possible directions. Every day, an animal rotates according to its currently active gene and moves one step forward.
- Energy Management: Living and moving costs energy. Consumption of plants restores it. If energy reaches zero, the animal is removed from the simulation.
- Reproduction & Inheritance:
- Crossover: Offspring inherit genes from two parents, with the split point determined by the parents' energy ratio.
- Mutation: A randomized number of genes are altered to new values, ensuring genetic drift and the possibility of adapting to new conditions.
This implementation introduces a dynamic climate system that significantly alters survival strategies:
- Summer: High plant productivity and standard energy consumption.
- Winter: Plant growth slows down significantly.
- Thermoregulation Logic: During winter, survival depends on social behavior. Animals must stay in close proximity to others (at least 2 neighbors in a specific radius) to "huddle" for warmth. Isolated animals suffer a significantly higher energy drain due to the cold.
The application follows a modular, decoupled architecture leveraging JavaFX and the Model-View-Presenter (MVP) pattern to separate the simulation engine from the graphical interface.
model.elements: Core entities (Animal,Genome) and factory classes.model.systems: The core "engine" containing discrete logic forMovementSystem,EatingSystem,BreedingSystem, andGrassGenerator.model.policies: Implements the Strategy Pattern to handle different energy consumption and gain rules (Standard vs. Seasonal).model.world: Handles spatial logic, map directions, and environmental states (Seasons, Climate).service: Utility services for file I/O (CSV statistics export), configuration management (PresetManager), and simulation threading.view&presenter: Handle high-performance rendering, live charts, and user input.
Quality and logic correctness are ensured through a comprehensive testing suite using JUnit 5:
- Logic Verification: Tests for gene crossover, mutation probability, and movement patterns.
- System Integrity: Validation of energy consumption policies, specifically focusing on the temperature-dependent drain in the "Seasons" variant.
- Concurrency: Ensuring the simulation remains stable when running multiple instances simultaneously.
- Configuration & Presets: Upon startup, users can define all simulation parameters (initial energy, mutation rates, seasonal lengths) and save them as Presets for future use.
- Multi-Simulation Engine: Run multiple independent simulations concurrently in separate windows to compare different evolutionary outcomes.
- Advanced Statistics: Real-time tracking of population size, plant count, free fields, average energy, and genotype dominance.
- Animal Tracking: Users can pause the simulation and select a specific animal to monitor its lineage, descendants, and detailed biography.
- Visualization: Dynamic coloring based on energy levels and visual highlights for preferred growth zones and dominant genotypes.
- Requirements: Java 17+ and JavaFX.
- Launch: Execute the application via
Launcher.java. - Execution: Configure your environment in the main menu and click "Start" to begin the simulation. Use the UI controls to pause, resume, or export data to CSV.
- Wiktor Trybus along with one colleague
Developed as a final project for the "Object-Oriented Programming" (Programowanie Obiektowe) course at AGH University of Science and Technology (Faculty of Computer Science, 2025/2026).