Zing Forum

Reading

Neural Network-Driven Ecosystem Evolution Simulator

This article introduces an ecosystem simulation project integrating neural networks and genetic algorithms, demonstrating how to simulate the dynamic evolution process of predators, prey, and plants using AI technology, and providing both Web interface and desktop dual-mode experience.

神经网络生态系统模拟遗传算法人工生命捕食者-猎物模型PyTorchFastAPI进化计算
Published 2026-06-05 00:14Recent activity 2026-06-05 00:23Estimated read 7 min
Neural Network-Driven Ecosystem Evolution Simulator
1

Section 01

[Introduction] Project Overview of Neural Network-Driven Ecosystem Evolution Simulator

This article introduces an ecosystem simulation project that integrates neural networks and genetic algorithms, aiming to reproduce the dynamic evolution process of predators, prey, and plants through AI technology. The project provides both Web interface and desktop dual-mode experience. Its core is to let virtual creatures make behavioral decisions via neural networks and achieve evolution through genetic algorithms, offering an intuitive tool for understanding complex systems and evolutionary computation. The original project is maintained by sanikprogramist, sourced from GitHub (link: https://github.com/sanikprogramist/Neural-Network-Ecosystem-Stimulation), published on June 4, 2026.

2

Section 02

Project Background and Research Significance

Natural ecosystems have complex interactions. How to reproduce these dynamics through computational models is a classic topic in the cross field of AI and computational biology. This project responds to this demand by building an evolving ecosystem simulator, where virtual creatures (herbivores, predators) use neural networks as their 'brains' to make behavioral decisions and are driven to evolve via genetic algorithms, exploring the essence of life and intelligence.

3

Section 03

Core Mechanisms and Ecological Balance Design

The core mechanisms of the project include:

  1. Neural network-driven behavior: Animals receive environmental inputs (vision, hunger state, etc.) and output decisions such as movement and attack. Behaviors are adaptive strategies rather than fixed patterns.
  2. Genetic algorithm evolution: Population evolution is promoted through mutation (random changes in neural network weights), natural selection (survivors reproduce), and fitness evaluation (survival time, predation success rate, etc.).
  3. Three-level food chain balance: Plants (basic resources) → herbivores → predators. The system spontaneously tends to dynamic balance, simulating real ecological population fluctuations.
4

Section 04

Technical Implementation and Architecture

The tech stack includes Python3.10+, PyTorch (neural networks), FastAPI+Uvicorn (Web backend), Pygame (desktop visualization), etc. The code structure consists of main.py (entry), class_world.py (world logic), app.py (FastAPI service), etc. The Web end exposes endpoints like /state (simulation state), /chart (statistical data), and /step (advance simulation) via FastAPI, supporting remote observation and experiment management.

5

Section 05

Interactive Features and Visualization

The desktop mode (Pygame) supports operations such as pressing the R key to toggle ray vision, the space bar to deselect an animal, the S key to generate more creatures, and clicking the mouse to view animal details. Data visualization includes population dynamic charts (changes in the number of herbivores/predators) and fitness distribution charts (population fitness statistics), intuitively showing ecological fluctuations and evolution effects.

6

Section 06

Educational and Research Value

In education, it is a teaching tool for understanding complex systems, emergent behavior, and evolutionary computation, allowing observation of phenomena such as complex behavior arising from simple rules and populations shaped by natural selection. In research, it is an extensible experimental platform for evolutionary algorithms, where users can modify neural network architectures, selection pressure parameters, environmental conditions, etc. Additionally, it provides inspiration for cross research between AI and biology, exploring the essence of artificial life.

7

Section 07

Deployment and Operation Guide

Environment preparation: Install dependencies (pip install numpy pandas torch scipy fastapi uvicorn). Web mode: Start with uvicorn app:app --reload and visit http://127.0.0.1:8000. Desktop mode: Run python main.py.

8

Section 08

Key Insights and Future Outlook

Project insights:

  1. Simple neural networks can drive complex behaviors.
  2. Evolution (mutation + selection) can spontaneously produce adaptive strategies.
  3. Simple individual rules converge into complex population dynamics (emergence). Future applications include teaching demonstrations, algorithm research, or curiosity exploration, serving as a good starting point for artificial life and evolutionary computation.