Export Code

Ecosystem Simulation

Nita

Last edited Apr 01, 2025
Created on Apr 01, 2025
Forked from HTML Starter

Ecosystem Simulation

This is a simple ecosystem simulation that shows the interaction between different organisms in a virtual environment.

Entities

The simulation includes three types of entities:

  1. Plants (green): Generate energy through photosynthesis and reproduce slowly.
  2. Herbivores (blue): Consume plants for energy and reproduce when they have enough energy.
  3. Carnivores (red): Hunt and consume herbivores for energy.

Controls

  • Start: Begin the simulation
  • Pause: Pause the simulation
  • Reset: Reset the simulation with initial entities

Ecosystem Rules

  • All entities have limited energy and age.
  • Plants generate energy and grow over time.
  • Herbivores seek and eat plants to gain energy.
  • Carnivores hunt herbivores to gain energy.
  • All entities reproduce when they have sufficient energy.
  • Entities die when they run out of energy or reach their maximum age.

How It Works

The ecosystem maintains a balance naturally. If there are too many herbivores, they will consume more plants, causing the plant population to decline. With fewer plants, herbivores will struggle to find food and their population will decrease. This will allow the plant population to recover. Similar dynamics occur between herbivores and carnivores.

This is a simple demonstration of predator-prey relationships and ecosystem dynamics.

MIT Licensed