Author: Grzegorz Mróz
Darwin Game is a Java/JavaFX simulation of evolving animals living on a map. Each day the simulation advances through a full lifecycle: movement, feeding, reproduction, plant growth, and seasonal effects. The application includes a graphical UI for configuring and running the simulation, as well as CSV export of statistics for later analysis.
- Interactive simulation UI built with JavaFX and FXML.
- Configurable parameters (map size, energy values, mutation strategy, etc.) via a launcher screen.
- Day-by-day simulation loop with a single control interface for running, pausing, and stepping.
- Genome-based behavior with random generation and crossover.
- Statistics export to CSV files for offline analysis.
- Unit tests for core model classes.
Use Gradle tasks to build and run the application:
- Build:
gradlew build - Run:
gradlew run
- Install JDK 17+.
- Open the project root in your IDE.
- Use the Gradle wrapper script for your OS:
- Windows: gradlew.bat
- macOS/Linux: gradlew
- Run the tasks listed above to build and start the app.
- UI layouts: src/main/resources/launcher.fxml, src/main/resources/simulation.fxml
- Java sources: src/main/java
- Tests: src/test/java
Examples:
- Model:
Simulation,DarwinMap,Animal,SimulationConfig - View: FXML layouts defined in src/main/resources/launcher.fxml and src/main/resources/simulation.fxml
- Controller/Presenter:
LauncherPresenter,SimulationPresenter
Purpose: Separates responsibilities:
- Model holds the business logic and data without UI dependencies.
- View defines the visual layout only.
- Controller reacts to user actions and synchronizes model ↔ view.
Example: Simulation
Purpose:
Wraps the full “day cycle” into a simple control API (run, stepForward, pause). This hides the internal sequence of steps (remove dead animals, move, eat, reproduce, grow plants, apply seasonal effects) behind one clear interface.
Example: Genome with factory methods random and crossover
Purpose: Encapsulates complex genotype creation logic and exposes a clean, input-driven construction API.
Simulation results are exported as CSV files in the project root (e.g., statistics_2026-01-24_22-45-10.csv). These include daily metrics such as population size, average energy, and genotype diversity.
Unit tests cover the core model logic, including vector math, directions, genomes, and animal behavior. Run tests with:
gradlew test