Skip to content

Grzmro/Darwin-Game

Repository files navigation

Darwin Game

Author: Grzegorz Mróz


Overview

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.


Key Features

  • 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.

How to Run

Use Gradle tasks to build and run the application:

  • Build: gradlew build
  • Run: gradlew run

Run Locally (Quick Setup)

  1. Install JDK 17+.
  2. Open the project root in your IDE.
  3. Use the Gradle wrapper script for your OS:
  4. Run the tasks listed above to build and start the app.

Project Structure


Architecture & Design Patterns

1. Model-View-Controller (MVC)

Examples:

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.

2. Facade

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.

3. Factory

Example: Genome with factory methods random and crossover

Purpose: Encapsulates complex genotype creation logic and exposes a clean, input-driven construction API.


Statistics Output

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.


Testing

Unit tests cover the core model logic, including vector math, directions, genomes, and animal behavior. Run tests with:

  • gradlew test

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages