Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ecosystem Simulator

Python Pygame

Play directly in your browser:
https://ootake0914-dotcom.github.io/ecosystem-sim/

Ecosystem Animation

Note: This project was created by extracting the core Python simulator from the original ESP32 Ecosystem Simulator and evolving it into a highly-optimized, standalone PC version.

A highly optimized, aesthetic artificial life and ecosystem simulation written in Python. Watch an entire ecosystem evolve in real-time as creatures compete for survival, adapt through genetic evolution, and form a complex food web.

Features

  • Real Genetic Evolution: Entities pass down genetic traits (Speed, Immunity, Altruism) to their offspring with mutation. Natural selection occurs in real-time!
  • Optimized Spatial Hash Grid: Uses advanced $O(1)$ local search structures instead of $O(N^2)$ iteration, allowing thousands of entities to interact smoothly without frame drops.
  • Complex 5-Tier Ecosystem: Includes Plants, Herbivores, Carnivores, Apex Predators, and Decomposers interacting with Spores (diseases) and Garbage (decaying matter).
  • Rich Visuals: Features a neon, minimalist aesthetic with dynamic glowing tails and smooth animations powered by Pygame.

Installation

  1. Ensure you have Python 3.9+ installed.
  2. Clone this repository.
  3. Install the required dependencies:
    pip install -r requirements.txt

How to Run

Execute the main Pygame simulation:

python main.py

Running in the Browser (WebAssembly)

This project is fully compatible with pygbag, allowing you to run it directly in a web browser!

  1. Install pygbag:
    pip install pygbag
  2. Build and serve the web version:
    pygbag .
  3. Open the provided localhost link in your browser to watch the simulation run on the web!

Architecture

  • sim.py: Contains the core headless simulation logic, including the SpatialHashGrid and entity logic (Herbivore, Carnivore, etc.).
  • sim_pygame.py: Handles rendering, inputs, particle effects, and the Pygame application loop.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages