Skip to content

✨🧬 A self-evolving AI biosphere leveraging LSTM/REINFORCE for adaptation. Full technical documentation available on the website.

License

Notifications You must be signed in to change notification settings

alwaysvivek/evolving-ai-biosphere

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌍 Evolving AI Biosphere

A living digital world where AI organisms evolve and adapt through memory, learning, and survival.


πŸ“š Table of Contents

  1. 🧠 Overview
  2. πŸ–ΌοΈ Demo Snapshot
  3. 🧬 Species Overview
  4. 🌦️ Environment Dynamics
  5. βš™οΈ Energy Flow
  6. πŸ§ͺ Scent Diffusion System
  7. 🧭 Emergent Phenomena
  8. 🧬 Reproduction & Inheritance
  9. πŸ’€ Death & Decay
  10. πŸ•ΉοΈ Interactive Controls
  11. 🎨 Visual Feedback
  12. πŸ“Š Long-Term Dynamics
  13. βš™οΈ Installation & Setup
  14. ▢️ Running the Simulation
  15. πŸŒ‹ Test Ecosystem Resilience
  16. 🧠 Study Hive Learning
  17. 🧩 Custom Scenarios
  18. πŸ“ˆ Reporting
  19. 🌍 Summary

🧠 Overview

Evolving AI Biosphere (formerly AI Ecosphere) is a self-evolving artificial life simulation where three species β€” plants, herbivores, and predators β€” interact in a dynamic, learning-based ecosystem.

Unlike static simulations, organisms here use neural networks and reinforcement learning to evolve emergent behaviors β€” adapting, learning, and surviving across generations.

A digital petri dish where machine learning meets natural selection.

🧩 Technical Documentation:
Basically, how it all comes together β€” visit the full docs at
πŸ‘‰ https://alwaysvivek.github.io/evolving-ai-biosphere/


πŸ–ΌοΈ Demo Snapshot

Generation 100 β€” stabilized biosphere (plant dominance phase):

Generation 100 Snapshot

Description:
A dynamic view of the AI Ecosphere at Generation 100. The dark, textured terrain is populated by three species: Plants (Green), Predators (Red), and sparse Herbivores (Blue), alongside Nutrient Deposits (Yellow).
Notice the emergence of distinct territories: a dense central Plant Forest protected by clustered, actively hunting predators, and areas of high Plant Scent (green halos) indicating concentrated resources.
The top-left overlay confirms the critical environmental balance: a high population (277) but a low, yet stable, Diversity Score (0.71).

πŸ“„ View raw simulation log:
logs/sample_output.txt


🧬 Species Overview

🌱 Plants (Green)

Sessile organisms that generate energy via photosynthesis and reproduce asexually when conditions allow.

Life Cycle:

  • Gain energy from light; reproduce at 130+ energy (splitting energy with offspring)
  • Die from old age (350+ cycles), overcrowding, low light, or herbivore consumption
  • Emit scent signals to attract herbivores

Key Stats:

  • Max Energy: 150
  • Photosynthesis: +3.5 energy/cycle
  • Metabolism: -0.4 energy/cycle
  • Death in low light (< 0.18 intensity)

πŸ‡ Herbivores (Blue)

Mobile agents that eat plants and flee predators using their own LSTM neural networks.

Behavior Systems:

  • Foraging: Seek plant-rich areas via scent gradients
  • Predator Avoidance: Escape zones with predator presence
  • Energy Management: Balance eating, resting, and reproducing
  • Reproduction: At 90+ energy (with mutated neural weights)

LSTM Inputs (8):

  1. Nearby plant count
  2. Herbivore count
  3. Predator count
  4. Nutrient count
  5. Energy level
  6. Age factor
    7–8. Random noise (exploration)

Outputs: Reproduce, move/hunt, rest, or idle.


🦊 Predators (Red)

Apex hunters governed by a collective LSTM Hive Mind β€” all predators share one evolving neural brain.

Life Cycle:

  • Feed on herbivores (+120 energy per kill)
  • Reproduce at 100+ energy
  • Die from starvation or old age (600+ cycles)

Hive Mind Learning:

  • All predators share experiences (observations, rewards, actions)
  • Every 20 generations, the Hive trains via REINFORCE
  • Collective intelligence leads to evolved group strategies (e.g., flanking, trapping prey)

🌦️ Environment Dynamics

πŸ”† Spatial Light Field

  • Varies across the map (bright β†’ plant-rich, dark β†’ barren)
  • Affects plant growth and energy efficiency

🌑️ Temperature

  • Fluctuates between 0.0–1.0
  • Alters metabolism and photosynthesis efficiency

🌘 Global Light Cycle

  • Varies between 0.3–1.0 to simulate day/night cycles

πŸͺ¨ Nutrient Spawning

  • Random nutrient deposits boost local ecosystem growth

βš™οΈ Energy Flow

Energy drives survival β€” all species gain and spend it differently:

Flow Source β†’ Target Description
β˜€οΈ Light β†’ Plants Photosynthesis
🌿 Plants β†’ Herbivores Foraging
🩸 Herbivores β†’ Predators Hunting
πŸ”₯ All Metabolism & movement drain

Balance:
Overgrowth in one level causes cascading effects β€” predator crashes, herbivore booms, plant depletion, etc.


πŸ§ͺ Scent Diffusion System

Chemical scent fields create indirect perception:

Scent Type Emitted By Function
🌿 Plant Scent Plants Attracts herbivores
🐾 Herbivore Scent Herbivores Attracts predators

Each scent diffuses outward over 3 steps, creating gradient maps for navigation.


🧭 Emergent Phenomena

The AI-driven evolution leads to realistic ecological dynamics:

  • Boom–Bust Cycles: Natural oscillations in population sizes
  • Spatial Clustering: Territory and colony formation
  • Behavioral Evolution: Learned evasion and hunting strategies
  • Extinction Events: Permanent loss of species reshapes balance
  • Monoculture Dominance: Single-species takeovers causing fragility

🧬 Reproduction & Inheritance

Species Inheritance Type Mutation
🌱 Plants Asexual cloning None
πŸ‡ Herbivores Neural weight mutation Β±0.01 (2% chance)
🦊 Predators Hive-mind training Collective evolution

πŸ’€ Death & Decay

Cause Description
Starvation Energy depletion
Old Age Beyond max lifespan
Predation Eaten by higher species
Overcrowding Excess neighbors (plants)
Light Starvation Insufficient local light
Random Events Manual extinction events

πŸ•ΉοΈ Interactive Controls

Key Action
SPACE Play/Pause simulation
C Clear all organisms
R Generate statistical report
T Toggle Hive training
F Spawn flower pattern
S Spawn spiral formation
O Predator swarm
N Nutrient field
K Kill all predators
L Kill all herbivores
P Kill all plants
E Scarcity event
Q Quit simulation

🎨 Visual Feedback

  • Colors: Green=Plant, Blue=Herbivore, Red=Predator
  • Brightness: Indicates energy level
  • Scent Halos: Faint green/red glows show chemical concentrations
  • Background: Noise-based soil texture that shifts with temperature and light
  • HUD Overlay: Displays population stats, generation count, diversity, temperature, and hive experience

πŸ“Š Long-Term Dynamics

Phase Description
0–50 generations Unstable bursts and population crashes
50–200 generations Evolved equilibrium and specialization
200+ generations Stable biomes, learned behaviors, and possible extinctions

Each major extinction or scarcity event permanently alters ecosystem balance.


βš™οΈ Installation & Setup

βœ… Prerequisites

  • Python 3.7+
  • Basic GPU/CPU for 800Γ—800 rendering (30 FPS)

πŸ“¦ Installation

  1. Clone or Download Repository
    git clone https://github.com/<your-username>/evolving-ai-biosphere.git
    cd evolving-ai-biosphere
  2. Install dependencies
     pip3 install -r requirements.txt
  3. Run simulation
      python3 main.py

▢️ Running the Simulation

Then press:

  1. SPACE β†’ Start simulation
  2. R β†’ View stats report periodically
  3. Watch the populations evolve for 50–100 generations

πŸŒ‹ Test Ecosystem Resilience

  • Let the world stabilize
  • Press K β†’ Wipe predators
  • Observe herbivore explosion and eventual plant collapse

🧠 Study Hive Learning

  • Press T β†’ Disable predator training (baseline)
  • Press T again β†’ Re-enable and wait 20+ generations
  • Compare predator coordination and efficiency

🧩 Custom Scenarios

  • C β†’ Clear world
  • F β†’ Add plants
  • O β†’ Add predators
  • SPACE β†’ Begin evolution

πŸ“ˆ Reporting

Press R anytime to generate:

  • Generation count
  • Total and per-species population
  • Temperature and light levels
  • Diversity score (Shannon entropy)
  • Total births and deaths
  • Hive training status

🌍 Summary

Evolving AI Biosphere creates a sandbox of digital evolution, where:

  • Neural agents adapt and learn
  • The Hive Mind evolves collectively
  • Nature’s balance unfolds through machine learning

A glimpse into how life might look when evolution is powered by AI.

About

✨🧬 A self-evolving AI biosphere leveraging LSTM/REINFORCE for adaptation. Full technical documentation available on the website.

Topics

Resources

License

Stars

Watchers

Forks

Languages