Skip to main content
100%

Ecosystem Simulation

✓ Published0🌍 Public
NNita
Last edited Apr 1, 2025
Created on Apr 1, 2025
Forked from HTML Starter

This animated ecosystem simulation visualizes predator-prey dynamics among three interacting species: plants, herbivores, and carnivores. Using the HTML5 Canvas API with `getContext('2d')` and `requestAnimationFrame`, the simulation renders colored circles representing each organism as they move, consume, reproduce, and die. Population statistics update in real-time, demonstrating natural population oscillations as each species' survival depends on the abundance of others.

AI-generated description

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

Similar vizzes