https://github.com/alwaysvivek/evolving-ai-biosphere
A self-evolving AI biosphere leveraging LSTM/REINFORCE for adaptation.
https://github.com/alwaysvivek/evolving-ai-biosphere
ai artificial-intelligence biology deep-learning devops evolutionary-algorithms machine-learning mlflow mlops numpy python3 pytorch reinforcement-learning simulation torch
Last synced: 2 months ago
JSON representation
A self-evolving AI biosphere leveraging LSTM/REINFORCE for adaptation.
- Host: GitHub
- URL: https://github.com/alwaysvivek/evolving-ai-biosphere
- Owner: alwaysvivek
- License: mit
- Created: 2025-11-03T17:28:03.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2026-01-13T09:43:52.000Z (5 months ago)
- Last Synced: 2026-01-13T11:40:01.054Z (5 months ago)
- Topics: ai, artificial-intelligence, biology, deep-learning, devops, evolutionary-algorithms, machine-learning, mlflow, mlops, numpy, python3, pytorch, reinforcement-learning, simulation, torch
- Language: Python
- Homepage: https://alwaysvivek.github.io/evolving-ai-biosphere/
- Size: 508 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ๐ Evolving AI Biosphere
A self-evolving digital ecosystem where AI organisms fight for survival, powered by Reinforcement Learning and Genetic Algorithms.



[](https://github.com/alwaysvivek/evolving-ai-biosphere/actions/workflows/static.yml)
## ๐ Overview
**Evolving AI Biosphere** is a complex artificial life simulation where organisms are not pre-programmed with rulesโthey **learn** how to survive.
- **Predators** share a collective "Hive Mind" (LSTM Neural Network) that evolves via Reinforcement Learning (Policy Gradient).
- **Herbivores** evolve individually via Genetic Algorithms (mutation of weights).
- **The World** is watched by an "AI God" (Ollama/Llama 3.2) that allows natural language control over the simulation.
๐ **[Read the Full Technical Documentation](docs/index.html)** for a deep dive into the math, architecture, and evolutionary theory.
### ๐ธ Demo

---
## ๐ Tech Stack
| Component | Technology | Description |
| :--- | :--- | :--- |
| **Core Engine** | Python, Pygame | Real-time simulation loop (60 FPS) and rendering. |
| **Neural Nets** | PyTorch | Custom LSTM architecture for Predator "Hive Mind". |
| **Orchestration** | Python `subprocess` | Multi-threaded service manager (`launch_services.py`). |
| **Inference** | Ollama | Local LLM serving (Llama 3.2) for God Mode control. |
| **Observability** | MLflow | Real-time experiment tracking and metric logging (Port 5001). |
---
## ๐งฉ Architecture
```mermaid
graph LR
%% Styling
classDef infra fill:#f9f,stroke:#333,stroke-width:2px;
classDef core fill:#bbf,stroke:#333,stroke-width:2px;
classDef brain fill:#bfb,stroke:#333,stroke-width:2px;
%% --- Infrastructure (Left Column) ---
subgraph Infrastructure
direction TB
Launch[launch_services.py]:::infra
Ollama["Ollama Service
(Llama 3.2)"]:::infra
MLflow["MLflow Server
(Metrics)"]:::infra
Launch -.->|Starts| Ollama
Launch -.->|Starts| MLflow
end
%% --- Simulation (Middle Column) ---
subgraph "Simulation Loop (60hz)"
direction TB
User[User Input]
Pygame[Pygame Engine]:::core
Grid[NumPy Grid State]:::core
User ==>|Controls| Pygame
Pygame ==>|Updates| Grid
end
%% --- Intelligence (Right Column) ---
subgraph "The Hive & Agents"
direction TB
Preds["Predator Hive Mind
(PyTorch LSTM)"]:::brain
Herbs["Herbivores
(Genetics)"]:::brain
God["God Mode Agent
(LangChain)"]:::brain
Council["Council System
(LangGraph)"]:::brain
end
%% --- Connections (Critical Paths) ---
%% Bio-Loop
Grid <==>|Sensors/Action| Preds
Grid <==>|Sensors/Action| Herbs
%% God Mode Loop
Pygame -.->|Chat| God
God <==>|Tools| Pygame
God -.->|Inference| Ollama
%% Council Loop
God -- Summon --> Council
Council -.->|Debate| Ollama
%% Logging
Pygame -- Log Data --> MLflow
```
---
## ๐ Installation & Setup
### Prerequisites
- **Python 3.9+**
- **Ollama** installed and running (`llama3.2` model pulled).
### 1. Clone the Repository
```bash
git clone https://github.com/alwaysvivek/evolving-ai-biosphere.git
cd evolving-ai-biosphere
```
### 2. Setup Virtual Environment
We provide a unified script to set up the environment and install dependencies:
```bash
# Make the script executable
chmod +x setup_env.sh
# Run the setup (creates venv and installs all requirements)
./setup_env.sh
```
---
## ๐ฎ How to Run
### Step 1: Start Background Services
This script starts **MLflow** (logging) and checks for **Ollama** (AI Brain).
```bash
python3 launch_services.py
```
*Wait until you see: `โ
MLflow UI started at http://127.0.0.1:5001`*
### Step 2: Run the Simulation
Open a **new terminal tab/window**, activate the environment, and run:
```bash
source venv/bin/activate
python3 simulation.py
```
---
## ๐ฎ Controls
| Key | Action |
| :--- | :--- |
| **SPACE** | Pause/Resume Simulation |
| **Type** | Enter "God Mode" commands (e.g., "kill half the plants") |
| **R** | Print Console Report |
| **T** | Toggle Predator Training (ON/OFF) |
| **K** | Kill All Predators (Extinction Event) |
| **E** | Trigger Scarcity Event (Famine) |
---
## ๐ Monitoring
Once the simulation starts, open **MLflow** to see live metrics including population counts, average energy, and extinction events:
๐ **http://127.0.0.1:5001**
---
## ๐ License
MIT License