This project is a cellular automaton simulation developed as an academic task for the Biological Computation Course. It models complex environmental interactions using a particle-based system.
- Educational Focus: Designed to demonstrate the capabilities of cellular automata for academic study and research.
- Complete Configuration Control: Configure properties for every aspect of the simulation, including pollution dynamics, temperature changes, water transfer, and more.
- Robust Core Logic: The heart of the simulation lies in the
corefolder, which meticulously implements the cellular automaton behavior. - Graphical User Interface:
- Real-time visualization of simulation results
- Logging:
- Info-level messages printed to the console
- Detailed debug logs saved to
simulation.log
βββ main.py # Main entry point for the simulation
βββ config/ # Configuration management files
β βββ presets.py # Presets for simulation configuration
β βββ Config.py # Handles configuration validation and updates (Config Singleton Instance)
βββ core/ # Core simulation logic
β βββ Particle.py # Manages particle behavior in the simulation
β βββ Simulation.py # Main simulation engine
β βββ World.py # Manages the simulation world/environment
β βββ __init__.py # Initialization file for the core module
βββ display/ # Visualization components
β βββ MatplotlibDisplay.py # Handles Matplotlib-based visualization
β βββ __init__.py # Initialization file for the display module
βββ docs/ # Documentation and resources
β βββ GUI.png # Screenshot or image of the GUI
βββ scripts/ # Shell/Batch Scripts for dev automation and utilities
β βββ build.bat # Script to compile the project into an executable
β βββ clean_git_ignored.sh # Script to delete all ignored files and folders
β βββ git_update.sh # Script to update the repository
β βββ zip_non_ignored.sh # Script to zip non-ignored files
βββ utils/ # Utility functions
β βββ helpers.py # Helper functions for the project
βββ .gitignore # Git ignore file
βββ README.md # Project documentation
βββ requirements.txt # Python dependencies
The configuration properties are the foundation of this simulation. Each property can be modified to customize the behavior and environment.
days: Simulation Duration (Days).grid_size: Grid Dimensions(X, Y, Z).initial_ratios: Proportions of cell types (e.g.,forest,city, etc.).
baseline_temperature: Baseline Temperature (Β°C).baseline_pollution_level: Baseline Pollution Levels.
cell_type_pollution_transfer_weights: Pollution Transfer Weights by Cell Type.
cell_type_temperature_transfer_weights: Temperature Transfer Weights by Cell Type.
cell_type_water_transfer_weights: Water Transfer Weights by Cell Type.
forest_pollution_absorption_rate: Rate at which forests absorb pollution.forest_cooling_effect: Cooling effect of forests on the environment.forest_pollution_extinction_point: Pollution level beyond which forests die.forest_temperature_extinction_point: Temperature beyond which forests die.
city_pollution_generation_rate: Rate of pollution generation by cities.city_warming_effect: Warming effect caused by cities.city_temperature_extinction_point: Maximum temperature for city survival.city_pollution_extinction_point: Pollution level beyond which cities collapse.
freezing_point: Temperature (Β°C) at which water freezes.melting_point: Temperature (Β°C) at which ice melts.evaporation_point: Temperature (Β°C) at which water evaporates.
water_transfer_threshold: Minimum water mass difference for transfer.water_transfer_rate: Rate of water transfer between cells.ocean_conversion_threshold: Water mass required to convert a cell to ocean.
pollution_damage_threshold: Pollution level causing damage to ecosystems.pollution_level_tipping_point: Pollution level beyond which damage accelerates.natural_pollution_decay_rate: Rate at which pollution naturally decays.
natural_temperature_decay_rate: Rate at which temperature equalizes to baseline.
cloud_saturation_threshold: Minimum water mass for clouds to precipitate.
melting_rate: Rate at which ice melts.evaporation_rate: Rate at which water evaporates.
cell_type_collision_weights: Weights governing cell-type collisions.
base_colors: RGBA colors for each cell type.
- Graphs:
- Pollution trends over time.
- Average temperature and water mass.
- Cell type population counts and standard deviations.
- 3D Visualization:
- Displays the grid and cell types with their interactions and transformations.
- Results and metrics are logged in
simulation.logfor further analysis and also are printed in the CLI. - Metrics include averages, standard deviations, and configuration details.
Particle.py: Defines the behavior of individual cells, including pollution absorption, water transfer, and type-specific interactions.Simulation.py: Manages the simulation lifecycle, precomputing states for multiple days and tracking metrics.World.py: Represents the grid and initializes particles using elevation maps.
MatplotlibDisplay.py: Generates graphs and 3D visualizations.- Real-Time GUI: Displays metrics and allows interaction during the simulation.
- Run the program:
python main.py
- Choose a configuration preset or define your custom setup.
- Observe the simulation progress through the GUI.
- CLI output example can be found in the
cli_outputfile. - GUI Screenshot

- Python 3.11.x
The program depends on the following Python libraries:
numpy==1.24.4noise==1.2.2matplotlib==3.9.3
Download the project files to your local machine.
- Clone this repository or download the ZIP file:
git clone https://github.com/v1t3ls0n/Cellular-Automaton cd Cellular-Automaton
- Open a terminal (Linux/Bash or Command Prompt on Windows).
- Navigate to the project directory:
cd path/to/project - Install the required libraries using
pip:pip install -r requirements.txt
- Navigate to the project directory:
cd path\to\project - Run the program:
python main.py
- Navigate to the project directory:
cd path/to/project - Run the program:
python3 main.py
When prompted, select one of the following options:
- Default Configuration Preset: Uses pre-defined default parameters.
- Choose Preset: Select from a list of predefined presets (e.g., low pollution, high pollution).
- Custom Parameters: Define every property manually.
- After selecting a configuration, the program validates it and begins the simulation.
- Progress is displayed in real time through a graphical interface.
- Ensure PyInstaller is installed:
pip install pyinstaller
- Run the following command to bundle the project into a standalone
.exefile:C:\Users\Studio\AppData\Local\Programs\Python\Python311\Scripts\pyinstaller --onefile ^ --add-data "config/*.py;config" ^ --add-data "core/*.py;core" ^ --add-data "display/*.py;display" ^ --add-data "utils/*.py;utils" ^ main.py
- The executable will be located in the
rootfolder folder:main.exe
-
Install PyInstaller and the necessary cross-compilation tools:
pip install pyinstaller sudo apt-get install mingw-w64
-
Use the
--winoption withPyInstallerto specify a Windows target:pyinstaller --onefile \ --add-data "config/*.py:config" \ --add-data "core/*.py:core" \ --add-data "display/*.py:display" \ --add-data "utils/*.py:utils" \ --name main.exe \ main.py -
The compiled
.exefile will be located in therootfolder:./main.exe
-
Missing Dependencies: Ensure all required libraries are installed:
pip install -r requirements.txt
-
Executable Closes Immediately: Run the executable from a terminal or Command Prompt to view error messages:
./main.exe
-
FileNotFoundError: Ensure all
--add-datapaths are correctly specified during compilation.
- Console Output: Info-level messages are printed to the console.
- File Logging: Detailed logs are saved to
simulation.log.
This project is an independent academic submission for the Biological Computation Course. The implementation, configuration, and logic have been designed solely by Guy Vitelson.