Play directly in your browser:
https://ootake0914-dotcom.github.io/ecosystem-sim/
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.
- 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.
- Ensure you have Python 3.9+ installed.
- Clone this repository.
- Install the required dependencies:
pip install -r requirements.txt
Execute the main Pygame simulation:
python main.pyThis project is fully compatible with pygbag, allowing you to run it directly in a web browser!
- Install pygbag:
pip install pygbag
- Build and serve the web version:
pygbag . - Open the provided
localhostlink in your browser to watch the simulation run on the web!
sim.py: Contains the core headless simulation logic, including theSpatialHashGridand entity logic (Herbivore,Carnivore, etc.).sim_pygame.py: Handles rendering, inputs, particle effects, and the Pygame application loop.
MIT
