A Research-Grade Artificial Life Simulation
Ananke is an autonomous artificial life system where AI-driven agents navigate a resource-scarce world, make decisions via LLM cognition, evolve through reproduction, and compete for survival. Watch life emerge from simple rules.
- ๐ง LLM-Powered Cognition: Each agent thinks using Google Gemini, deciding actions based on perception, memory, and internal drives.
- ๐งฌ Genetic Evolution: Agents reproduce with mutation. Over generations, successful traits propagate.
- โก Energy Economics: Survival requires finding and consuming resources. Every action has a cost.
- ๐ Rich Telemetry: Every event is logged for offline analysis and replay.
- ๐ Web Visualizer: A real-time dashboard to observe the simulation.
# 1. Clone and enter the project
cd ananke
# 2. Setup the environment
make setup
# 3. Set your API key
export GEMINI_API_KEY="your_key_here"
# 4. Run the simulation with live visualization
make startThen open http://localhost:8000 to observe!
ananke/
โโโ agent/ # Agent internals (Brain, Genome, Drives, Memory)
โโโ world/ # Environment (Grid, Resources, Physics)
โโโ system/ # Runtime loop, Telemetry, Safety Governor
โโโ tools/ # Visualization & Analytics
โ โโโ web_visualizer.py # FastAPI + Canvas Dashboard
โ โโโ analytics.py # Matplotlib trend analysis
โโโ main.py # Entry point
โโโ config.py # Tunable parameters
โโโ Makefile # Commands
| Command | Description |
|---|---|
make setup |
Create venv and install all dependencies |
make start |
Run simulation + web visualizer together |
make run |
Run simulation only (terminal output) |
make web |
Run web visualizer only |
make analytics |
Generate analytics plots from telemetry logs |
make clean |
Remove logs and generated files |
Perception โ Internal State โ Goal Generation โ Action โ Outcome โ Memory Update
โ
Reflection & Learning
- Grid: 100x100 discrete cells
- Resources: Spawn randomly, provide energy when consumed
- Partial Observability: Agents only see within a perception radius
- Agents can reproduce when they have sufficient energy
- Child genomes are mutated copies of the parent
- Selection pressure emerges naturally from survival
After running a simulation, analyze the data:
make analyticsThis generates analytics_report.png with:
- Population Dynamics over time
- Trait vs Outcome scatter plots (e.g., Risk Tolerance vs Lifespan)
- Evolutionary pressure correlations showing which traits are being selected
Ananke is built for rigorous scientific research:
# config.py
RANDOM_SEED = 42 # Set for reproducible experiments (None for random)Every simulation logs its seed, so you can reproduce exact results.
Agents can mate when close enough, combining genes from two parents:
- Uniform crossover: Each gene randomly selected or blended from parents
- Mutation: Small random changes after crossover
- Controlled via
SEXUAL_REPRODUCTION,CROSSOVER_RATE,MATING_RADIUS
10 heritable traits that influence behavior:
| Trait | Range | Effect |
|---|---|---|
risk_tolerance |
0-1 | Exploration vs caution |
curiosity |
0-1 | Movement patterns |
social_bias |
0-1 | Interaction tendency |
aggression |
0-1 | Competition behavior |
cooperation |
0-1 | Resource sharing |
memory_retention |
0-1 | Learning from past |
metabolism_efficiency |
0.5-2.0 | Energy cost multiplier |
reproduction_threshold |
0.2-0.8 | Energy % to trigger reproduction |
perception_acuity |
0.5-1.5 | Vision range multiplier |
lifespan_factor |
0.8-1.5 | Natural lifespan |
Every agent tracks:
- Generation number
- Parent IDs (1 or 2 for sexual reproduction)
- Full ancestor chain
- Lifetime statistics (energy, children, demon influence, etc.)
After each simulation, data is exported to research_data/:
research_data/
โโโ simulation_*_summary.json # High-level metrics
โโโ simulation_*_population.csv # Time series data
โโโ simulation_*_agents.json # All agent records
โโโ simulation_*_generations.csv # Per-generation statistics
โโโ simulation_*_correlations.json # Trait-fitness correlations
โโโ simulation_*_demon_influence.csv
Automatically computes Pearson correlation between each genome trait and fitness score, revealing evolutionary selection pressure.
The dashboard at localhost:8000 provides:
| Feature | Description |
|---|---|
| Ghost Trails | Fading paths showing agent movement history |
| Energy View | Heatmap mode showing agent health via color |
| Time Controls | Speed up (100x) or pause the replay |
| Agent Inspector | Hover to see genome, energy, and lineage |
Edit config.py to tune:
# Reproducibility
RANDOM_SEED = 42 # Set to None for random
# World
WORLD_WIDTH = 100
WORLD_HEIGHT = 100
# Genetics
MUTATION_RATE = 0.1
CROSSOVER_RATE = 0.7
SEXUAL_REPRODUCTION = True
# Cognition
LLM_MODEL_NAME = "gemini-2.5-pro"| Variable | Required | Description |
|---|---|---|
GEMINI_API_KEY |
Yes | Your Google AI API key |
Create a .env file in the project root:
GEMINI_API_KEY=your_api_key_here
- Governor: Enforces population caps and simulation timeouts
- Read-Only Telemetry: Observer cannot influence the simulation
- Kill Switch: Governor can terminate runaway simulations
MIT
"Life finds a way."