eighthill / Slime_Mold_Simulation

A student project simulating smile mold🧫
MIT License
6 stars 0 forks source link

How to use Slime Mold Simulation

Introduction

This document provides guidance on how to get the slime mold simulation program running on your computer. This simulation visualizes the complex behavior of slime mold agents as they navigate and interact in their environment.

Installation

Before you begin, ensure you have Python installed on your computer. This program requires at least Python 3.8 and several dependencies, including Vispy, a library for interactive scientific visualization.

Steps for Installation:

  1. Install Pyhton 3.8 or newer from the offical Pyhton website.
  2. Download the Program: Ensure you have all Files in a Folder. click here to download
  3. Install Dependencies: Open your terminal or command prompt and navigate to the program's directory. Install the required Python libraries.
    • pip install vispy
    • pip install numpy
    • pip intall scipy
    • pip install PyQt5

Starting the Program

After you have made all the installations, you can start the simulation program.

  1. Open Terminal/Command Prompt: Navigate to the folder via
    • cd ~/.../Silme_Mold_Simulation
  2. Run the Program: Execute the following command.
    • python Gui.py This will launch the graphical user interface

What you can do in the program

Our Program creates a virtual environment where our slime / mold agents interact with each other. These agents simulate the behavior of real mold by moving to areas with higher concentrations of a virtual substance (pheromones) in the environment. As the agents move, they leave a trail (pheromones) that can attract other agents. The simulation includes processes that show how these pheromones diffuse and fade over time, and how the agents decide where to go based on the pheromones they detect. This shows intelligent behavior that can be traced back to the real unicellulars from the real world. The agents creat intersting patterns/pathways. Depending on the parameters you can visualize very different behivours.

The agents are visualized as small black dots, while the pheromone trail has a purple to yellow color. Yellow = high pheromone values / purple = low pheromone values

Using manual

The simulation can get unstable really easy. Especially the Sensor Angle and Randome factor can brake the agents so they stop moving! We have collected some parameters which can help out in the beginning. Set the values for each simulation and restart the simulation for simillar results.

Example parameters:

Agent speed: 2 Agent count: 50000 Decay: 0,9 Diffusion coefficent: 0,95 Sensor distance: 10 Rotation speed: 0,3 Sensor Angle: 26 Randome factor: 0,1 Visual:

Example1


Agent speed: 4 Agent count: 50000 Decay: 0,97 Diffusion coefficent: 0,97 Sensor distance: 15 Rotation speed: 0,2 Sensor Angle: 5 Randome factor: 0,02 Visual:

Example2


For Developer

Developer Documentation

The documentation is especially for developers who are interested in getting a better understanding of our program. Here you will find a detailed overview of how the classes and methods are structured and how they interact. You are also welcome to give us feedback for the code, if something was programmed too complicated or anything else :).

First of all, we decided to structure everything as well as possible. This means that the simulation was not written in one file, but the logic of the simulation is in one file (simulation.py), the Gui (Gui.py), Config (config.py) and the sliders (Ui_Slider_logic.py) are each in separate files so that they can be better separated.

Code structure as a diagram

diagramofcode

Simulation

So let's look specifically at our logic, that's the heart of the program where everything is done. This is where the magic happens, where the agents find their way.This file is designed to simulate the complex, emergent behavior of slime molds using a combination of agent-based modeling and pheromone interaction mechanics.

Config

We have also separated the parameters into a config so that everything is more dynamic and easier to understand.

Gui

Next, let's take a look at the Gui. The Gui.py file implements the graphical user interface (GUI) for the slime mold simulation using Vispy, a Python library for interactive scientific visualization and PyQT5 for the interface with sliders to adjust simulation parameters dynamically. These sliders control aspects such as agent speed and count, directly the simulation's behavior. It defines a SimulationGUI class that initializes the simulation environment, including the pheromone array and agent instances, and sets up a Vispy canvas for visualization. This class handles drawing the agents and pheromone levels on the canvas and updates these visuals in response to simulation changes. Key functionalities include initiating the simulation GUI, drawing and updating visuals based on simulation data, and managing periodic updates through a timer event. This GUI component is crucial for visualizing the simulation's dynamics and interacting with the simulation parameters in real-time.

Slider

The Ui_Slider_logic.py script integrates interactive elements into the slime mold simulation GUI, specifically focusing on PyQt5 sliders and buttons for dynamic configuration. It features: We have a class here SliderLogic Class:

Runtime analysis

The February 2024 Final Version boasts a constant runtime complexity, a stark departure from Version 0's linear increase. Regardless of agent numbers, the Final Version consistently outperforms its predecessor. Despite initial compilation overhead, the NUMBA-optimized Final Version showcases superior performance, underscoring its enhanced efficiency and scalability. More about that can be read in Issue 68 by now.

Feedback

Thank you for your attention so far, now you have gained an understanding of how our program works. We wish you a lot of fun trying out parameters which result in beautiful patterns, you are welcome to send us pictures, short videos of how your settings. We would be very happy to receive feedback. If you have any suggestions for improvement or criticism, please feel free to contact us. We are looking forward to improve the simulation :)